#include#include #define S(n) scanf("%d",&n)#define F(i,n) for(int i=1;i<=n;i++)using std::max;int a[110][110],T,m,n,f;main(){S(T);F(b,T){m=0;S(n);F(i,n)F(j,i)S(f),m=max(m,a[i][j]=f+max(a[i-1][j],a[i-1][j-1]));printf("%d\n",m);}}
本文共 316 字,大约阅读时间需要 1 分钟。
#include#include #define S(n) scanf("%d",&n)#define F(i,n) for(int i=1;i<=n;i++)using std::max;int a[110][110],T,m,n,f;main(){S(T);F(b,T){m=0;S(n);F(i,n)F(j,i)S(f),m=max(m,a[i][j]=f+max(a[i-1][j],a[i-1][j-1]));printf("%d\n",m);}}
转载于:https://www.cnblogs.com/avema/p/3774248.html