[恢]hdu 2084
2011-12-16 04:39:01
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2084
题意:中文~经典dp。
代码:
# include <stdio.h>
int dp[110][110] ;
int max(int a, int b){return a>b?a:b;}
int main ()
{
int T, n, i, j ;
scanf ("%d", &T) ;
while (T--)
{
scanf ("%d", &n) ;
for (i = 1 ; i <= n ; i++)
for (j = 1 ; j <= i ; j++)
scanf ("%d", &dp[i][j]) ;
for (i = n-1 ; i >= 1 ; i--)
{
for(j = 1; j <= i ; j++)
dp[i][j] += max(dp[i+1][j], dp[i+1][j+1]) ;
}
printf ("%d\n", dp[1][1]) ;
}
}