Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:求0MS代码In Reply To:求0MS代码 Posted by:adps2010_09274014 at 2010-07-31 19:36:00 > 0MS是怎么做到的呢 求代码 #include <iostream> using namespace std; #define MAX(x,y) ((x)>(y)?(x):(y)) const int MAXN = 101; int main() { int i,n,j; int a[MAXN][MAXN]={0}; scanf("%d",&n); for(i=1;i<=n;++i) for(j=1;j<=i;++j) { scanf("%d",&a[i][j]); a[i][j]+=MAX(a[i-1][j],a[i-1][j-1]); } int max=-1; for(i=1;i<=n;++i) if(max<a[n][i])max=a[n][i]; printf("%d\n",max); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator