标签:include using open namespace i+1 rac c++ max end
///1、输入
cin>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=i;j++)
{
cin>>a[i][j];
}
//2、逆推
//a[i][j]=max{a[i][j]+a[i+1][j],a[i][j]+a[i+1][j+1]}
for(int i=n-1;i>=1;i--)
for(int j=1;j<=i;j++)
{
if(a[i+1][j]>a[i+1][j+1]) a[i][j]+=a[i+1][j];
else a[i][j]+=a[i+1][j+1];
}
cout<<a[1][1]<<endl;
return 0;
}
标签:include using open namespace i+1 rac c++ max end
原文地址:http://blog.51cto.com/1443208/2328979