1 条题解

  • 1
    @ 2026-10-1 20:01:50
    #include <iostream>
    using namespace std;
    
    typedef long long LL;
    const LL mod=1e9+7;
    
    LL T,n;
    LL jc[5000010];
    LL inv[5000010];
    
    LL comb(LL a,LL b){
        return jc[a]*inv[b]%mod*inv[a-b]%mod;
    }
    
    LL power(LL a,LL b){
        LL ans=1;
        while(b>0){
            if(b&1){
                ans=ans*a%mod;
            }
            a=a*a%mod;
            b>>=1;
        }
        return ans;
    }
    
    int main(){
        freopen("seq.in","r",stdin);
        freopen("seq.out","w",stdout);
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        cin>>T;
        jc[0]=1;
        for(LL i=1;i<=5000000;i++){
            jc[i]=jc[i-1]*i%mod;
        }
        inv[5000000]=power(jc[5000000],mod-2);
        for(LL i=4999999;i>=0;i--){
            inv[i]=inv[i+1]*(i+1)%mod;
        }
        while(T--){
            cin>>n;
            if(n%4!=1){
                cout<<"0\n";
                continue;
            }
            if(n==1){
                cout<<"2\n";
                continue;
            }
            cout<<2*comb(n/2,n/4)%mod*comb(n/2-1,n/4)%mod<<'\n';
        }
        return 0;
    }
    
    
    • 1

    信息

    ID
    3681
    时间
    600ms
    内存
    1024MiB
    难度
    8
    标签
    递交数
    55
    已通过
    8
    上传者