[恢]hdu 2048
2011-12-16 02:05:33
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2048
题意:中文。
mark:算错拍概率。7以上不变了- -。。。
代码:
# include <stdio.h>
# include <string.h>
long long dp[25] = {0, 0, 1} ;
long long factorial[25] = {1, 1, 2} ;
int main ()
{
int i ;
for(i = 3 ; i <= 20 ; i++)
{
dp[i] = (i-1)*(dp[i-1]+dp[i-2]) ;
factorial[i] = factorial[i-1]*i ;
}
scanf ("%d", &i) ;
while (~scanf ("%d", &i))
printf ("%.2lf%%\n", 1.0*dp[i] / factorial[i] * 100.0) ;
return 0 ;
}