令我郁闷的一道题
编程爱好者acm的一个题目:
Number Triangle
Consider the number triangle shown below. Write a program that calculates the highest sum of numbers that can be 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 the right.如输入
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
结果为30
说明:从第一行开始,加上下一行与他相邻的数(选一个),输出最后得出的和最大的情况。
如上面的列子:结果为7+3+8+7+5=30。
实在想不出来了才想到你们,,哎~~~
祝论坛越来越好~~~~~