hdu 4535 错排
题意:错排
链接:点我
百年难得一遇大水题
1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 #include<map> 8 using namespace std; 9 #define MOD 1000000007 10 const int INF=0x3f3f3f3f; 11 const double eps=1e-5; 12 #define cl(a) memset(a,0,sizeof(a)) 13 #define ts printf("*****\n"); 14 const int MAXN=1005; 15 int n,m,tt; 16 long long f[110]; 17 void init() 18 { 19 f[1]=0; 20 f[2]=1; 21 for(int i=3;i<=100;i++) 22 { 23 f[i]=f[i-1]+f[i-2]; 24 f[i]%=MOD; 25 f[i]*=(i-1); 26 f[i]%=MOD; 27 } 28 } 29 int main() 30 { 31 int i,j,k; 32 #ifndef ONLINE_JUDGE 33 freopen("1.in","r",stdin); 34 #endif 35 scanf("%d",&tt); 36 init(); 37 while(tt--) 38 { 39 scanf("%d",&n); 40 printf("%I64d\n",f[n]); 41 } 42 }