[恢]hdu 2085
2011-12-15 04:37:17
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2085
题意:中文。裸递推。
代码:
# include <stdio.h>
long long dp[40][2] = {1, 0} ;
int main ()
{
int i, n ;
for (i = 1 ; i<= 33 ; i++)
{
dp[i][0] = dp[i-1][0]*3 + dp[i-1][1]*2 ;
dp[i][1] = dp[i-1][0] + dp[i-1][1] ;
}
while (~scanf ("%d", &n) && n != -1)
printf ("%I64d, %I64d\n", dp[n][0], dp[n][1]) ;
return 0 ;
}