赞
踩
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19683 Accepted Submission(s): 8350
1 2
50.00%
递推的推导错排公式
- #include"stdio.h"
- #define N 21
- int main()
- {
- int i,n,t;
- __int64 sum,f[N];
- f[1]=0;
- f[2]=1;
- for(n=3;n<N;n++)
- f[n]=(n-1)*(f[n-1]+f[n-2]);
- scanf("%d",&t);
- while(t--)
- {
- scanf("%d",&n);
- sum=1;
- for(i=2;i<=n;i++)
- sum*=i;
- printf("%.2f%%\n",100.0*f[n]/sum);
- }
- return 0;
- }
-
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。