hihocoder#1037 : 数字三角形 经典简单动态规划
2015-07-14 12:53
489 查看
http://hihocoder.com/problemset/problem/1037
#include<map> #include<vector> #include<cstdio> #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<cmath> #include<stack> #include<queue> #include<set> #define inf 0x3f3f3f3f #define mem(a,x) memset(a,x,sizeof(a)) using namespace std; typedef long long ll; typedef pair<int,int> pii; inline int in() { int res=0;char c; while((c=getchar())<'0' || c>'9'); while(c>='0' && c<='9')res=res*10+c-'0',c=getchar(); return res; } int maze[111][111]; int main() { int n=in(); for(int i=0;i<n;i++) { for(int j=0;j<=i;j++) { scanf("%d",&maze[i][j]); } } for(int i=n-1;i>=0;i--) { for(int j=0;j<=i;j++) { maze[i][j] += max(maze[i+1][j],maze[i+1][j+1]); } } printf("%d\n",maze[0][0]); return 0; }
相关文章推荐
- 一、状态压缩dp(2)送披萨
- 一些想法
- SVN笔记---使用过程中的报错
- 用EasyDarwin开发分布式流媒体服务器
- JNI实现回调| JNI调用JAVA函数|参数和返回值的格式
- tomcat移除项目名和端口号
- VS2010显示行号
- 向两边展开的Floating Action Button
- android大概是通过logcat拦截Log
- SQLlite使用、创建、插入、修改、查询
- shell脚本调试
- shell脚本调试
- JavaMail解析邮件内容(经典收藏)
- 套接字的使用
- ACM的算法分类
- 输入一个十进制数N,将它转换成R进制数输出(运用递归实现)
- shell脚本调试
- iOS——MVVM设计模式
- shell脚本调试 分类: 学习笔记 linux ubuntu 2015-07-14 12:49 53人阅读 评论(0) 收藏
- Largest Redis Clusters Ever