結果

問題 No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│
ユーザー tko919tko919
提出日時 2019-12-04 22:52:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 403 ms / 5,000 ms
コード長 2,353 bytes
コンパイル時間 1,520 ms
コンパイル使用メモリ 169,768 KB
実行使用メモリ 38,504 KB
最終ジャッジ日時 2023-08-21 05:00:33
合計ジャッジ時間 8,400 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
38,416 KB
testcase_01 AC 141 ms
38,164 KB
testcase_02 AC 142 ms
38,240 KB
testcase_03 AC 145 ms
37,852 KB
testcase_04 AC 143 ms
38,404 KB
testcase_05 AC 143 ms
38,164 KB
testcase_06 AC 143 ms
38,116 KB
testcase_07 AC 143 ms
37,848 KB
testcase_08 AC 144 ms
38,404 KB
testcase_09 AC 143 ms
38,320 KB
testcase_10 AC 143 ms
37,896 KB
testcase_11 AC 142 ms
38,216 KB
testcase_12 AC 142 ms
38,292 KB
testcase_13 AC 143 ms
38,152 KB
testcase_14 AC 143 ms
38,408 KB
testcase_15 AC 159 ms
37,848 KB
testcase_16 AC 200 ms
37,948 KB
testcase_17 AC 260 ms
38,344 KB
testcase_18 AC 295 ms
38,092 KB
testcase_19 AC 259 ms
38,216 KB
testcase_20 AC 340 ms
38,308 KB
testcase_21 AC 220 ms
38,504 KB
testcase_22 AC 332 ms
38,408 KB
testcase_23 AC 202 ms
37,852 KB
testcase_24 AC 336 ms
38,408 KB
testcase_25 AC 375 ms
37,892 KB
testcase_26 AC 403 ms
38,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

int mod=1e9+7;
struct Mint {
    int val;
    Mint inv() const{
        int tmp,a=val,b=mod,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return Mint(x);
    }
public:
    Mint():val(0){}
    Mint(ll x){if((val=x%mod)<0)val+=mod;}
    Mint pow(ll t){Mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    Mint& operator+=(const Mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
    Mint& operator-=(const Mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
    Mint& operator*=(const Mint& x){val=(ll)val*x.val%mod; return *this;}
    Mint& operator/=(const Mint& x){return *this*=x.inv();}
    Mint operator+(const Mint& x) const{return Mint(*this)+=x;}
    Mint operator-(const Mint& x) const{return Mint(*this)-=x;}
    Mint operator*(const Mint& x) const{return Mint(*this)*=x;}
    Mint operator/(const Mint& x) const{return Mint(*this)/=x;}
};
struct factorial {
    vector<Mint> Fact, Finv;
public:
    factorial(int maxx){
        Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
        Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
    }
    Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
    Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
    Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

factorial fact(3000010);
Mint coeff[3000010];

int main(){
    int x,y,z; scanf("%d%d%d",&x,&y,&z);
    if(x==0&&y==0&&z==0){printf("1\n"); return 0;}
    int n=x+y+z+1;
    rep(i,0,n+1)coeff[i]=fact.nCr(n,i)*((n-i)&1?-1:1);
    coeff[0]-=1;
    rep(i,0,n)coeff[i]/=-2,coeff[i+1]-=coeff[i];
    Mint ans;
    rep(i,0,n)ans+=fact.nCr(i+x-1,x)*fact.nCr(i+y-1,y)*fact.nCr(i+z-1,z)*coeff[i];
    printf("%d\n",ans.val);
    return 0;
}
0