[恢]hdu 2046
2011-12-14 06:19:27
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2046
题意:中文。。。
mark:递推,dp[i] = dp[i-1] + dp[i-2]。要用long long
代码:
# include <stdio.h>
long long dp[60] = {0, 1, 2} ;
int main ()
{
int i, n ;
for (i = 3 ; i <= 50 ; i++)
dp[i] = dp[i-1] + dp[i-2] ;
while (~scanf ("%d", &n))
printf ("%I64d\n", dp[n]) ;
return 0 ;
}