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