結果
問題 | No.895 MESE |
ユーザー | lumc_ |
提出日時 | 2019-09-27 21:40:29 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 7,672 bytes |
コンパイル時間 | 1,010 ms |
コンパイル使用メモリ | 104,752 KB |
実行使用メモリ | 8,304 KB |
最終ジャッジ日時 | 2024-09-24 21:02:35 |
合計ジャッジ時間 | 2,393 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
8,156 KB |
testcase_01 | AC | 11 ms
8,120 KB |
testcase_02 | AC | 10 ms
7,992 KB |
testcase_03 | AC | 9 ms
8,084 KB |
testcase_04 | AC | 10 ms
8,012 KB |
testcase_05 | AC | 10 ms
8,048 KB |
testcase_06 | AC | 9 ms
7,984 KB |
testcase_07 | AC | 10 ms
8,020 KB |
testcase_08 | AC | 9 ms
8,220 KB |
testcase_09 | AC | 11 ms
8,176 KB |
testcase_10 | AC | 10 ms
8,024 KB |
testcase_11 | AC | 11 ms
8,132 KB |
testcase_12 | AC | 11 ms
8,176 KB |
testcase_13 | AC | 22 ms
8,172 KB |
testcase_14 | AC | 19 ms
8,168 KB |
testcase_15 | AC | 23 ms
8,048 KB |
testcase_16 | AC | 21 ms
8,040 KB |
testcase_17 | AC | 17 ms
7,996 KB |
testcase_18 | AC | 27 ms
8,304 KB |
testcase_19 | AC | 27 ms
7,988 KB |
testcase_20 | AC | 27 ms
8,060 KB |
testcase_21 | AC | 27 ms
8,076 KB |
testcase_22 | AC | 28 ms
7,988 KB |
testcase_23 | AC | 27 ms
8,068 KB |
testcase_24 | AC | 27 ms
8,000 KB |
testcase_25 | AC | 27 ms
8,088 KB |
testcase_26 | AC | 28 ms
8,168 KB |
testcase_27 | AC | 27 ms
8,016 KB |
testcase_28 | AC | 27 ms
8,100 KB |
ソースコード
// includes {{{ #include<iostream> #include<iomanip> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<map> #include<set> #include<tuple> #include<cmath> #include<random> #include<cassert> #include<bitset> #include<cstdlib> // #include<deque> // #include<multiset> // #include<cstring> // #include<bits/stdc++.h> // }}} using namespace std; using ll = long long; // NOTE : use H with larger N /// --- Modulo Factorial {{{ /// #include <cassert> #include <cstddef> template < std::size_t N, int mod = static_cast< int >(1e9 + 7) > struct Factorial { using integer = long long; constexpr integer extgcd(integer a, integer b, integer &x, integer &y) { integer d = 0; return b == 0 ? (x = a < 0 ? -1 : 1, y = 0, a < 0 ? -a : a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d); } constexpr integer modinv(integer a) { integer x = 0, y = 0; extgcd(a, mod, x, y); if(x < 0) x += mod; else if(x == mod) x = 0; return x; } int arr[N + 1], inv[N + 1]; integer operator[](int i) const { return arr[i]; } Factorial() : arr(), inv() { arr[0] = 1; for(std::size_t i = 1; i <= N; i++) { arr[i] = (integer) i * arr[i - 1] % mod; } inv[N] = modinv(arr[N]); for(int i = N - 1; i >= 0; i--) { inv[i] = (integer)(i + 1) * inv[i + 1] % mod; } } integer C(int n, int r) const { if(n < 0 || r < 0 || n < r) return 0; assert(n <= N); return (integer) arr[n] * inv[r] % mod * inv[n - r] % mod; } integer H(int n, int r) const { return C(n + r - 1, r); } }; /// }}}--- /// constexpr int mod = 1e9 + 7; const int N = 3e5 + 10; Factorial< N * 2, mod > fact; /// --- Modulo Integer {{{ /// #include <ostream> template < long long mod = static_cast< long long >(1e9 + 7) > struct ModuloInteger { static_assert(mod > 0, "mod must be positive"); static_assert(mod <= 3037000499, "mod is too big"); using integer = long long; static ModuloInteger unused; // math {{{ static inline integer extgcd(integer a, integer b, integer &x, integer &y) { integer d; return b == 0 ? (x = a < 0 ? -1 : 1, y = 0, a < 0 ? -a : a) : (d = extgcd(b, a % b, y, x), y -= a / b * x, d); } static inline integer modinv(integer a) { integer x = 0, y = 0; extgcd(a, mod, x, y); if(x < 0) x += mod; else if(x == mod) x = 0; return x; } static inline integer modpow(integer a, long long b) { if(b < 0) b = -b, a = modinv(a); integer r = 1; a %= mod; while(b) { if(b & 1) r = r * a % mod; a = a * a % mod; b >>= 1; } return r; } // }}} integer val; constexpr ModuloInteger() : val(0) {} constexpr ModuloInteger(integer t) { val = t % mod; if(val < 0) val += mod; } private: // strict constructor constexpr ModuloInteger(integer t, int) : val(t) {} public: template < class T > explicit operator T() { return T(val); } // operator bool() { return bool(val); } // ModuloInteger <arithmetic-operator>[=] ModuloInteger {{{ ModuloInteger operator+(ModuloInteger const &rhs) const { ModuloInteger tmp = *this; tmp += rhs; return tmp; } ModuloInteger operator-(ModuloInteger const &rhs) const { ModuloInteger tmp = *this; tmp -= rhs; return tmp; } ModuloInteger operator*(ModuloInteger const &rhs) const { ModuloInteger tmp = *this; tmp *= rhs; return tmp; } ModuloInteger operator/(ModuloInteger const &rhs) const { ModuloInteger tmp = *this; tmp /= rhs; return tmp; } ModuloInteger &operator+=(ModuloInteger const &rhs) { val = val + rhs.val; if(val >= mod) val -= mod; return *this; } ModuloInteger &operator-=(ModuloInteger const &rhs) { return *this += -rhs; } ModuloInteger &operator*=(ModuloInteger const &rhs) { val = val * rhs.val % mod; return *this; } ModuloInteger &operator/=(ModuloInteger const &rhs) { return *this *= rhs.inv(); } // }}} // increment, decrement {{{ ModuloInteger operator++(int) { ModuloInteger tmp = *this; val = val + 1; if(val >= mod) val = 0; return tmp; } ModuloInteger operator--(int) { ModuloInteger tmp = *this; val = val == 0 ? mod - 1 : val - 1; return tmp; } ModuloInteger &operator++() { val = val + 1; if(val >= mod) val = 0; return *this; } ModuloInteger &operator--() { val = val == 0 ? mod - 1 : val - 1; return *this; } // }}} ModuloInteger operator-() const { return ModuloInteger(val == 0 ? 0 : mod - val, 0); } // ModuloInteger <arithmetic-operator>[=] T {{{ template < typename T > ModuloInteger operator+(T const &rhs) const { return ModuloInteger(val + rhs % mod); } template < typename T > ModuloInteger operator-(T const &rhs) const { return ModuloInteger(mod + val - rhs % mod); } template < typename T > ModuloInteger operator*(T const &rhs) const { return ModuloInteger(val * (rhs % mod)); } template < typename T > ModuloInteger operator/(T const &rhs) const { return ModuloInteger(val * modinv(rhs)); } template < typename T > ModuloInteger &operator+=(T const &rhs) { val = (mod + val + rhs % mod) % mod; return *this; } template < typename T > ModuloInteger &operator-=(T const &rhs) { val = (mod + val - rhs % mod) % mod; return *this; } template < typename T > ModuloInteger &operator*=(T const &rhs) { val = val * (mod + rhs % mod) % mod; return *this; } template < typename T > ModuloInteger &operator/=(T const &rhs) { val = val * modinv(rhs) % mod; return *this; } // }}} ModuloInteger inv() const { return ModuloInteger(modinv(val), 0); } ModuloInteger operator~() const { return inv(); } friend std::ostream &operator<<(std::ostream &os, ModuloInteger const &mv) { os << mv.val; return os; } // equality operator {{{ ModuloInteger operator==(const ModuloInteger &a) const { return val == a.val; } ModuloInteger operator!=(const ModuloInteger &a) const { return val != a.val; } ModuloInteger operator==(const integer &a) const { return val == ModuloInteger(a); } ModuloInteger operator!=(const integer &a) const { return val != ModuloInteger(a); } // }}} // T <arithmetic-operator> ModuloInteger {{{ friend constexpr ModuloInteger operator+(integer a, ModuloInteger const &mv) { return ModuloInteger(a % mod + mv.val); } friend constexpr ModuloInteger operator-(integer a, ModuloInteger const &mv) { return ModuloInteger(a % mod - mv.val); } friend constexpr ModuloInteger operator*(integer a, ModuloInteger const &mv) { return ModuloInteger((mod + a % mod) * mv.val % mod, 0); } friend constexpr ModuloInteger operator/(integer a, ModuloInteger const &mv) { return ModuloInteger((mod + a % mod) * modinv(mv.val) % mod, 0); } // }}} // power {{{ ModuloInteger operator^(integer x) const { return pow(*this, x); } ModuloInteger &operator^=(integer x) { val = modpow(val, x); return *this; } friend ModuloInteger pow(ModuloInteger x, integer y) { return ModuloInteger(modpow(x.val, y), 0); } // }}} }; template < long long mod > ModuloInteger< mod > ModuloInteger< mod >::unused(mod, 0); /// }}}--- /// using modint = ModuloInteger<>; int main() { std::ios::sync_with_stdio(false), std::cin.tie(0); int a, b, c; cin >> a >> b >> c; modint ans = 0; int n = a+b+c; for(int k = c; k <= n - 1 - 1; k++) { ans += modint(fact.C(k - c, b - 1)) * fact.C(k - 1, c - 1) * ((modint(2)^(k)) - 1); } cout << ans << endl; return 0; }