1573 88 1 0 2 7 4 44 5 2 6 5 Sample Output30 Source2006/1/15 ACM程序设计期末考试#include<iostream>#include<string>#include<math.h>#include<string.h>#include<stdio.h>#include<algorithm>using namespace std;int main(){ int num; cin>>num; while(num--) { int a[101][101],i,j,h; cin>>h; for(i=1;i<=h;i++) for(j=1;j<=i;j++) cin>>a[i][j]; for(i=h-1;i>=0;i--) for(j=1;j<=i;j++) a[i][j]+=max(a[i+1][j],a[i+1][j+1]);//每次取最大值 cout<<a[1][1]<<endl; } return 0;}
新闻热点
疑难解答