2011-12-14 05:42:17
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2041
题意:中文递推。
mark:dp[i] = dp[i-1] + dp[i-2]。用了long long,最大才102334155,int应该也可。
代码:
# include <stdio.h>
long long dp[50] = {0, 1, 1} ;
int main ()
{
int i, n ;
for (i = 3 ; i <= 40 ; i++)
dp[i] = dp[i-1]+dp[i-2] ;
scanf ("%d", &n) ;
while (~scanf ("%d", &n))
printf ("%I64d\n", dp[n]) ;
return 0 ;
}