Algorithm 版 (精华区)
发信人: Lerry (想不开·撞树), 信区: Algorithm
标 题: IOI'94 - Day 1 - Problem 1: The Triangle
发信站: 哈工大紫丁香 (2002年03月29日13:24:03 星期五), 站内信件
IOI'94 - Day 1 - Problem 1: The Triangle
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5 (Figure 1)
Figure 1 shows a number triangle. Write a program that calculates the highes
t sum of numbers passed on a route that starts at the top and ends somewhere
on the base.
Each step can go either diagonally down to the left or diagonally down to th
e right.
The number of rows in the triangle is >1 but <=100.
The numbers in the triangle, all integers, are between 0 and 99.
Input Data
Data about the number of rows in the triangle are first read from the INPUT.
TXT file. In our example, INPUT.TXT appears as follows:
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
Output Data
The highest sum is written as an integer in the OUTPUT.TXT file. In our exam
ple:
30
--
不在乎天长地久,就怕你从来没有!
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 天外飞仙]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.086毫秒