神、上帝以及老天爷
错排~
c[n] = (n-1) * (c[n-1] + c[n-2]);
c[1] = 0; c[2] = 1;
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 const int mod = 20090126; 5 const int maxn = 21; 6 ll c[maxn], f[maxn]; 7 void init(){ 8 c[1] = 0; 9 c[2] = 1; 10 for(int i = 3; i < maxn; i++) { 11 c[i] = (i-1) * (c[i-1] + c[i-2]); 12 } 13 f[1] = 1; 14 for(int i = 2; i < maxn; i++) f[i] = f[i-1] * i; 15 } 16 int main(){ 17 int n; 18 int t; 19 scanf("%d", &t); 20 init(); 21 while(t--) { 22 scanf("%d", &n); 23 printf("%.2lf",c[n]*100.0/f[n]); 24 puts("%"); 25 } 26 }
时间: 2024-11-07 11:02:38