标签:des style blog http color java os io
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 21741 Accepted Submission(s):
13099
1 #include<stdio.h> 2 #include<iostream> 3 #include<string.h> 4 using namespace std; 5 int dp[100][100],a[100][100]; 6 int main() 7 { 8 int t,i,j,n; 9 scanf("%d",&t); 10 while(t--) 11 { 12 scanf("%d",&n); 13 memset(dp,0,sizeof(dp)); 14 for(i=1; i<=n; i++) 15 for(j=1; j<=i; j++) 16 { 17 scanf("%d",&a[i][j]); 18 dp[i][j]=a[i][j]; 19 } 20 for(i=2; i<=n; i++) 21 for(j=1; j<=i; j++) 22 { 23 dp[i][j]=max(dp[i-1][j],dp[i-1][j-1])+a[i][j]; 24 } 25 int max=0; 26 for(i=1; i<=n; i++) 27 if(dp[n][i]>max) 28 max=dp[n][i]; 29 printf("%d\n",max); 30 } 31 return 0; 32 }
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/lxm940130740/p/3904819.html