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:有没有人输出每次路径,悲剧啊时间内存大1580K 63MS C 729BIn Reply To:有没有人输出每次路径,悲剧啊时间内存大1580K 63MS C 729B Posted by:200831000719 at 2010-11-26 15:50:24 从底层开始 动态规划 代码: #include <stdio.h> int max(int a,int b) { return a>b?a:b; } int main() { int i,j,n,a[351][351],b[351][351]; scanf("%d",&n); for(i=0;i<n;i++) for(j=0;j<=i;j++) scanf("%d",&a[i][j]); for(i=n-1;i>=0;i--) for(j=0;j<=i;j++) { if(i==n-1) b[i][j]=a[i][j]; else b[i][j]=max(b[i+1][j],b[i+1][j+1])+a[i][j]; } printf("%d\n",b[0][0]); return 0; } 我也想知道 0MS怎么实现的 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator