[恢]hdu 1465
2011-12-16 02:01:14
地址:http://acm.hdu.edu.cn/showproblem.php?pid=1465
题意:中文。。
mark:错拍问题。。。递推。dp[i] = (i-1) * (dp[i-1] + dp[i-2])
代码:
# include <stdio.h>
# include <string.h>
long long dp[25] = {0, 0, 1} ;
int main ()
{
int i ;
for(i = 3 ; i <= 20 ; i++)
dp[i] = (i-1)*(dp[i-1]+dp[i-2]) ;
while (~scanf ("%d", &i))
printf ("%I64d\n", dp[i]) ;
return 0 ;
}