結果

問題 No.940 ワープ ε=ε=ε=ε=ε=│;p>д<│
ユーザー chocoruskchocorusk
提出日時 2019-12-03 00:50:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 5,000 ms
コード長 1,586 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 111,068 KB
実行使用メモリ 23,800 KB
最終ジャッジ日時 2023-08-18 23:16:53
合計ジャッジ時間 2,982 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,628 KB
testcase_01 AC 2 ms
5,636 KB
testcase_02 AC 1 ms
5,408 KB
testcase_03 AC 3 ms
5,408 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
5,428 KB
testcase_06 AC 2 ms
5,404 KB
testcase_07 AC 2 ms
5,384 KB
testcase_08 AC 2 ms
5,328 KB
testcase_09 AC 2 ms
5,436 KB
testcase_10 AC 1 ms
5,332 KB
testcase_11 AC 1 ms
5,364 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,392 KB
testcase_14 AC 2 ms
5,336 KB
testcase_15 AC 11 ms
5,920 KB
testcase_16 AC 36 ms
11,560 KB
testcase_17 AC 72 ms
15,588 KB
testcase_18 AC 94 ms
15,580 KB
testcase_19 AC 70 ms
15,668 KB
testcase_20 AC 117 ms
19,652 KB
testcase_21 AC 45 ms
11,524 KB
testcase_22 AC 116 ms
19,664 KB
testcase_23 AC 35 ms
11,472 KB
testcase_24 AC 116 ms
19,788 KB
testcase_25 AC 141 ms
23,760 KB
testcase_26 AC 163 ms
23,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[5000001], invf[5000001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int x, y, z;
	cin>>x>>y>>z;
	if(x==0 && y==0 && z==0){
	    cout<<1<<endl;
	    return 0;
	}
	fac(x+y+z+1);
	ll c=0;
	for(int i=1; i<=x+y+z; i++){
		c+=powmod(2, i)*i;
		c%=MOD;
	}
	ll ans=0;
	ll p2=powmod(2, x+y+z+1);
	for(int m=1; m<=x+y+z; m++){
		ll s=comb(m, x)*comb(m, y)%MOD*comb(m, z)%MOD*c%MOD;
		if((m+x+y+z)&1){
			ans+=MOD-s;
		}else{
			ans+=s;
		}
		ans%=MOD;
		c=(p2*comb(x+y+z+1, m+1)%MOD+MOD-2*c%MOD)%MOD;
	}
	cout<<ans*((MOD+1)/2)%MOD<<endl;
    return 0;
}
0