sdut1730 数字三角形问题(dp入门题)
2015-07-12 11:01
453 查看
#include<stdio.h> int a[100][100]; int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) for(int j=1;j<=i;j++) scanf("%d",&a[i][j]); int maxx =0; for(int i=2;i<=n;i++) for(int j=1;j<=i;j++){ if(j == 1) a[i][j] += a[i-1][j]; else if(j == i) a[i][j] += a[i-1][j-1]; else if( (a[i][j] + a[i-1][j]) > (a[i][j] + a[i-1][j-1]) ) a[i][j] += a[i-1][j]; else a[i][j] += a[i-1][j-1]; if(a[i][j]>maxx) maxx = a[i][j]; } printf("%d",maxx); return 0; }
相关文章推荐
- performance Counter
- 配置文件读取properties(一)
- ConcurrentModificationException异常总结-多线程方式
- 一个简单链表的C++实现
- Motion Segmentation by Velocity Clustering with Estimationof Subspace Dimension阅读报告
- 记得有一个奇怪的ORA-04028: cannot generate diana for object
- 从1到n整数中1出现的次数
- DT大数据梦工厂
- 代码处理技巧
- Maven提高篇系列之——使用Profile
- 操作系统——IO管理
- nano使用说明
- HashMap与HashTable的区别
- hdu 4084
- 稀疏表示综述:A Survey of Sparse Representation: Algorithms and Applications_2015(1)
- 代码分析工具推荐Understand
- Unity定制,将属性暴露在Inspector面板上
- HTML5 – 1.基础
- spring MVC 文件执行顺序
- WIP jobs available to MRP