Problems B: permutations
Time limit: 1 Sec Memory Limit: 256 MB
Face questions
He declined to publicly face the question.
answer
$ C_n ^ i $ can be converted into $ C_n ^ {ni} $, I did not even want to think about this a little transformation ......
1e9 is not afraid to be a Li Lulu on the rooftop tossed.
Consider persimmon Significance: $ \ sum \ limits_ {i = 0} ^ nC_n ^ i * C_n ^ {ni} $ can be interpreted as elements selected from the group of n of 2n inside ......
Then it was over. $ C_ {2n} ^ n $, factorial direct and inverse play table. Complexity: $ O (n + T) $.
code:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<bits/stdc++.h> #define ll long long #define rint register int #define read(A) A=init() #define mod 1000000007 using namespace std; inline int init() { rint a=0,b=1;register char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')b=-1;ch=getchar();} while(ch>='0'&&ch<='9'){a=(a<<3)+(a<<1)+ch-'0';ch=getchar();} return a*b; } int T,n; ll inv[2000006],fac[2000006],facinv[2000006]; inline void getc() { inv[0]=inv[1]=fac[0]=facinv[0]=1; for(rint i=2;i<=2000000;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod; for(rint i=1;i<=2000000;++i) { fac[i]=fac[i-1]*i%mod; facinv[i]=facinv[i-1]*inv[i]%mod; } return ; } inline ll C(rint x,rint y){return fac[x]*facinv[x-y]%mod*facinv[y]%mod;} int main() { read(T);getc(); while(T--){read(n);printf("%lld\n",C(2*x,x));} return 0; }