标签:chmod line color others poi ++ break tip cond
Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
#include<bits/stdc++.h> using namespace std; #define ll long long #define pi (4*atan(1.0)) #define eps 1e-14 const int N=2e5+10,M=4e6+10,inf=1e9+10,mod=1e9+7; const ll INF=1e18+10; ll a[M]; ll inv[M]; void init() { inv[1] = 1; for(int i=2;i<=1000010;i++) { if(i >= mod)break; inv[i] = (mod - mod / i) * inv[mod % i]% mod; } } ll c[M]; int main() { a[0]=1; init(); for(ll i=1;i<=1000000;i++) { a[i]=(((a[i-1]*(4*i-2))%mod)*inv[i+1])%mod; } int T,cas=1; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); c[0]=1; for(int i=1,t=n;i<=n;t--,i++) { c[i]=(((c[i-1]*t)%mod)*inv[i])%mod; } ll ans=0; for(int i=0;i*2<=n;i++) { ans=(ans+(a[i]*c[2*i])%mod)%mod; } printf("%lld\n",ans); } return 0; }
标签:chmod line color others poi ++ break tip cond
原文地址:http://www.cnblogs.com/jhz033/p/6013541.html