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 |
一次AC,秒过,水题...贴出丑陋代码,勿笑...一次AC,秒过,水题...贴出丑陋代码,勿笑... #include <iostream> using namespace std; int main() { int inn=0,max=0; int n[100][100]={0}; int tmp[100]={0}; cin>>inn; for(int i=0;i<inn;i++) for(int j=0;j<=i;j++) cin>>n[i][j]; for(int i=1;i<inn;i++) for(int j=0;j<=i;j++) { int k; for(k=j;k>=j-1 && k>=0;k--) if(k<i) tmp[k]=n[i][j]+n[i-1][k]; k++; if(j>0 && j<i) n[i][j]=tmp[k]>tmp[k+1]?tmp[k]:tmp[k+1]; else if(j==0 || j==i) n[i][j]=tmp[k]; } for(int i=0;i<inn;i++) max=max>n[inn-1][i]?max:n[inn-1][i]; cout<<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