結果

問題 No.895 MESE
ユーザー koi_kotya
提出日時 2019-09-27 22:18:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,636 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 170,088 KB
実行使用メモリ 11,152 KB
最終ジャッジ日時 2024-09-24 17:30:24
合計ジャッジ時間 2,828 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;
#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while
    (0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it
    )->first << "=>" << (it)->second << ", ";}}while(0)
const int MAX_N = 300010;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];
ll pow_mod(ll a,ll b) {
ll ret;
if (b < 0) ret = pow_mod(a,mod+b-1);
else if (b == 0) ret = 1;
else if (b == 1) ret = a;
else {
ll c = pow_mod(a,b/2);
if (b%2) ret = (c*c)%mod*a%mod;
else ret = c*c%mod;
}
return ret;
}
void generate_table(int x) {
fact[0] = 1;fact[1] = 1;
for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
fact_inv[x] = pow_mod(fact[x],-1);
for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}
ll combi(ll a, ll b) {
return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}
int main() {
generate_table(300000);
int a,b,c;
cin >> a >> b >> c;
vector<ll> sum(a+1,0);
for (int i = 0;i < a;++i) sum[i+1] = fact[a+b+c-3-i]*fact_inv[a-i-1]%mod*fact_inv[b-1]%mod*fact_inv[c-1]%mod;
for (int i = 0;i < a;++i) (sum[i+1] += sum[i]) %= mod;
ll ans = 0;
ll d = 1;
for (int i = 0;i < a+b+c-2;++i) {
(ans += d*sum[min(a,a+b+c-i-2)]%mod) %= mod;
(d *= 2) %= mod;
}
cout << ans << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0