标签:style blog http io color for sp div log
刚开始还思路错了,百度了一下就思路就能写出来了http://acm.hdu.edu.cn/showproblem.php?pid=2084
1 #include <stdio.h> 2 3 int max(int a, int b) 4 { 5 return a>b ? a : b; 6 } 7 8 int main() 9 { 10 int T, n, i, j; 11 int dp[101][101]; 12 scanf("%d", &T); 13 while(T--) 14 { 15 scanf("%d", &n); 16 for(i=1; i<=n; i++) 17 { 18 for(j=1; j<=i; j++) 19 scanf("%d", &dp[i][j]); 20 } 21 for(i=n-1; i>=1; i--) 22 { 23 for(j=1; j<=i; j++) 24 dp[i][j] += max(dp[i+1][j], dp[i+1][j+1]); 25 } 26 printf("%d\n", dp[1][1]); 27 } 28 return 0; 29 }
标签:style blog http io color for sp div log
原文地址:http://www.cnblogs.com/forerve/p/4077291.html