POJ1163 The Triangle
2016-07-26 18:43
363 查看
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 44997 | Accepted: 27174 |
Description
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
(Figure 1)
Input
Your program is to read from standard input. The first line contains one integer N: the number of rows in the triangle. The following N lines describe the data of the triangle. The number of rows in the triangle is > 1 but <= 100. The numbers in the triangle, all integers, are between 0 and 99.Output
Your program is to write to standard output. The highest sum is written as an integer.Sample Input
5 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5
Sample Output
30
Source
IOI 1994
入门水题233
/**/ #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; int a[200][200]; int n; int main(){ scanf("%d",&n); int i,j; for(i=1;i<=n;i++) for(j=1;j<=i;j++) scanf("%d",&a[i][j]); for(i=n-1;i;i--) for(j=1;j<=i;j++){ a[i][j]+=max(a[i+1][j],a[i+1][j+1]); } printf("%d\n",a[1][1]); return 0; }
相关文章推荐
- centos7安装vncserver
- MATLAB - contour函数
- floyd算法
- 12.2 使用DROP INDEX删除索引
- struts2生成验证码
- Bzoj1007 水平可见直线
- 迪菲-赫尔曼密钥交换
- 软件开发进度表
- ELK修炼之道
- java多线程-生产者消费者经典问题
- centos7.1 将firewall 换成iptables
- 如何解决ajax跨域问题(转)
- Android中的基础----在按钮上显示图像的方式
- 纹理过滤模式中的Bilinear、Trilinear以及Anistropic Filtering
- 用户在线广告点击行为预测的深度学习模型
- css文件
- 淘宝内部分享:MySQL & MariaDB性能优化
- 多线程中使用CheckForIllegalCrossThreadCalls = false访问窗口
- hdu5754Life Winner Bo
- FFMPEG 实现 YUV,RGB各种图像原始数据之间的转换(swscale)