結果
問題 | No.895 MESE |
ユーザー |
![]() |
提出日時 | 2019-09-27 22:04:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 3,346 bytes |
コンパイル時間 | 1,718 ms |
コンパイル使用メモリ | 169,772 KB |
実行使用メモリ | 10,360 KB |
最終ジャッジ日時 | 2024-09-24 13:46:36 |
合計ジャッジ時間 | 3,018 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
/*** code generated by JHelper* More info: https://github.com/AlexeyDmitriev/JHelper* @author*/#include <iostream>#include <fstream>#ifndef SOLUTION_COMMON_H#include <bits/stdc++.h>using namespace std;using ll = long long;using PI = pair<int, int>;template<class T> using V = vector<T>;using VI = V<int>;#define _1 first#define _2 second#ifdef MY_DEBUG# define DEBUG(x) x#else# define DEBUG(x)#endiftemplate<class T>inline void debug(T &A) {DEBUG(for (const auto &a : A) {cerr << a << " ";}cerr << '\n';)}template<class T, class Func>inline void debug_with_format(T &A, Func f) {DEBUG(for (const auto &a : A) {cerr << f(a) << " ";}cerr << '\n';)}template<class T>inline void debug_dim2(T &A) {DEBUG(for (const auto &as : A) {debug(as);})}template<typename ... Args>inline void debug(const char *format, Args const &... args) {DEBUG(fprintf(stderr, format, args ...);cerr << '\n';)}template<typename ... Args>string format(const string &fmt, Args ... args) {size_t len = snprintf(nullptr, 0, fmt.c_str(), args ...);vector<char> buf(len + 1);snprintf(&buf[0], len + 1, fmt.c_str(), args ...);return string(&buf[0], &buf[0] + len);}template<class T1, class T2>string fmtP(pair<T1, T2> a) {stringstream ss;ss << "(" << a._1 << "," << a._2 << ")";return ss.str();}#define SOLUTION_COMMON_H#endif //SOLUTION_COMMON_Hclass Comb {public:int MOD;V<ll> F, I;Comb(int N, int MOD): MOD(MOD), F(N + 1), I(N + 1) {F[0] = 1;for (int i = 1; i <= N; ++i) {F[i] = F[i - 1] * i % MOD;}I[N] = pow_mod(F[N], MOD - 2, MOD);for (int i = N - 1; i >= 0; --i) {I[i] = I[i + 1] * (i + 1) % MOD;}}static ll pow_mod(ll x, int k, int MOD) {ll res = k >= 2 ? pow_mod(x * x % MOD, k / 2, MOD) : 1ll;if (k&1) res = res * x % MOD;return res;};ll operator()(int n, int k) {if (k < 0 || k > n) return 0ll;return F[n] * I[n - k] % MOD * I[k] % MOD;};ll rev(int x) {return F[x - 1] * I[x] % MOD;}};const int MOD = 1000000007;class D {public:void solve(std::istream& in, std::ostream& out) {int a, b, c;in >> a >> b >> c;int n = a + b + c;// cの、bit毎の現れる回数V<ll> cnt(n + 1);Comb comb(n, MOD);// 先頭のbの左側のaの個数で場合分けfor (int i = 1; i <= a; ++i) {int a1 = a - i;int b1 = b - 1;int n1 = n - i - 1;int bix = n - 1 - i; // 先頭のbの位置ll v = comb.F[n1]* comb.I[a1] % MOD* comb.I[b1] % MOD* comb.I[c] % MOD* c % MOD* comb.rev(bix) % MOD;debug("%d %d %d %d %lld", a1, b1, n1, bix, v);cnt[0] = (cnt[0] + v) % MOD;cnt[bix] = (MOD + cnt[bix] - v) % MOD;}for (int i = 0; i < n; ++i) {cnt[i + 1] = (cnt[i + 1] + cnt[i]) % MOD;}debug(cnt);ll ans = 0ll;ll pow2 = 1ll;for (int i = 0; i < n; ++i) {ans = ans + pow2 * cnt[i] % MOD;pow2 = pow2 * 2 % MOD;}ans %= MOD;out << ans;}};int main() {D solver;std::istream& in(std::cin);std::ostream& out(std::cout);solver.solve(in, out);return 0;}