結果

問題 No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│
ユーザー latte0119latte0119
提出日時 2019-12-04 15:02:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 4,121 bytes
コンパイル時間 4,142 ms
コンパイル使用メモリ 149,540 KB
実行使用メモリ 33,300 KB
最終ジャッジ日時 2023-08-20 13:30:33
合計ジャッジ時間 7,686 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
23,888 KB
testcase_01 AC 40 ms
24,104 KB
testcase_02 AC 40 ms
24,012 KB
testcase_03 AC 41 ms
23,792 KB
testcase_04 AC 41 ms
23,944 KB
testcase_05 AC 41 ms
23,888 KB
testcase_06 AC 42 ms
23,832 KB
testcase_07 AC 42 ms
24,020 KB
testcase_08 AC 41 ms
23,792 KB
testcase_09 AC 41 ms
24,004 KB
testcase_10 AC 41 ms
23,964 KB
testcase_11 AC 41 ms
23,796 KB
testcase_12 AC 41 ms
23,948 KB
testcase_13 AC 41 ms
24,012 KB
testcase_14 AC 40 ms
23,892 KB
testcase_15 AC 43 ms
24,480 KB
testcase_16 AC 46 ms
26,092 KB
testcase_17 AC 50 ms
28,304 KB
testcase_18 AC 53 ms
29,608 KB
testcase_19 AC 50 ms
28,172 KB
testcase_20 AC 56 ms
31,072 KB
testcase_21 AC 46 ms
26,636 KB
testcase_22 AC 56 ms
30,752 KB
testcase_23 AC 47 ms
26,232 KB
testcase_24 AC 55 ms
31,068 KB
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

template<uint32_t mod>
struct ModInt{
    uint32_t a;
    ModInt& s(uint32_t vv){
        a=vv<mod?vv:vv-mod;
        return *this;
    }

    ModInt(int64_t x=0){s(x%mod+mod);}

    ModInt& operator+=(const ModInt &x){return s(a+x.a);}
    ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
    ModInt& operator*=(const ModInt &x){
        a=uint64_t(a)*x.a%mod;
        return *this;
    }
    ModInt& operator/=(const ModInt &x){
        *this*=x.inv();
        return *this;
    }

    ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
    ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
    ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
    ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
    bool operator==(const ModInt &x)const{return a==x.a;}
    bool operator!=(const ModInt &x)const{return a!=x.a;}
    bool operator<(const ModInt &x)const{return a<x.a;}

    ModInt operator-()const{return ModInt()-*this;}
    ModInt pow(int64_t n)const{
        ModInt res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }

    ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,const ModInt<mod>& a){
    return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
    return (out<<a.a);
}
using mint=ModInt<1000000007>;

template<class Mint,int32_t lg>
struct ModIntTable{
    int N;
    vector<Mint>facts,finvs,invs;
    ModIntTable():N(1<<lg),facts(N),finvs(N),invs(N){
        const uint32_t mod=Mint(-1).a+1;
        invs[1]=1;
        for(int i=2;i<N;i++)invs[i]=invs[mod%i]*(mod-mod/i);

        facts[0]=1;
        finvs[0]=1;
        for(int i=1;i<N;i++){
            facts[i]=facts[i-1]*i;
            finvs[i]=finvs[i-1]*invs[i];
        }
    }
    inline Mint fact(int n)const{return facts[n];}
    inline Mint finv(int n)const{return finvs[n];}
    inline Mint inv(int n)const{return invs[n];}
    inline Mint binom(int n,int k)const{return facts[n]*finvs[k]*finvs[n-k];}
    inline Mint perm(int n,int k)const{return facts[n]*finvs[n-k];} 
};
ModIntTable<mint,20>mtable;
mint po[2222222];
signed main(){
    po[0]=1;
    for(int i=1;i<2222222;i++)po[i]=po[i-1]*2;

    int X,Y,Z;
    cin>>X>>Y>>Z;

    if(X==0&&Y==0&&Z==0){
        cout<<1<<endl;
        return 0;
    }


    int N=X+Y+Z;

    mint coef=po[N+1];
    if((N+1)&1)coef*=-1;

    vector<mint>p(N+2);
    for(int i=0;i<=N+1;i++){
        p[i]=coef*mtable.binom(N+1,i);
        if((N+1-i)&1)p[i]*=-1;
    }
    p[0]-=1;

    vector<mint>q(N+1);
    mint b=mint(2).inv();
    for(int i=N;i>=0;i--){
        mint c=p[i+1]*b;
        q[i]=c;
        p[i]+=c;
    }

    mint ans=0;
    for(int i=0;i<=N;i++){
        if(i<X||i<Y||i<Z)continue;
        mint tmp=q[i];
        tmp*=mtable.binom(i,X);
        tmp*=mtable.binom(i,Y);
        tmp*=mtable.binom(i,Z);
        ans+=tmp;
    }

    if(X&1)ans*=-1;
    if(Y&1)ans*=-1;
    if(Z&1)ans*=-1;
    ans/=2;
    ans*=-1;
    cout<<ans<<endl;
    return 0;
}
0