結果
問題 | No.2472 Tea time in the grand garden |
ユーザー | 👑 tute7627 |
提出日時 | 2023-10-29 18:50:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,571 bytes |
コンパイル時間 | 2,281 ms |
コンパイル使用メモリ | 205,748 KB |
実行使用メモリ | 15,220 KB |
最終ジャッジ日時 | 2024-09-25 16:51:25 |
合計ジャッジ時間 | 3,930 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
14,880 KB |
testcase_01 | WA | - |
testcase_02 | AC | 20 ms
14,972 KB |
testcase_03 | AC | 52 ms
14,752 KB |
testcase_04 | AC | 20 ms
15,080 KB |
testcase_05 | AC | 20 ms
14,908 KB |
testcase_06 | AC | 20 ms
14,908 KB |
testcase_07 | AC | 21 ms
15,028 KB |
testcase_08 | AC | 21 ms
14,900 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 20 ms
14,936 KB |
testcase_13 | AC | 50 ms
14,940 KB |
testcase_14 | AC | 52 ms
14,912 KB |
testcase_15 | AC | 52 ms
14,932 KB |
testcase_16 | AC | 21 ms
14,924 KB |
testcase_17 | AC | 21 ms
14,944 KB |
testcase_18 | AC | 21 ms
14,912 KB |
testcase_19 | AC | 21 ms
14,964 KB |
testcase_20 | AC | 20 ms
14,932 KB |
testcase_21 | AC | 20 ms
14,948 KB |
testcase_22 | AC | 21 ms
14,932 KB |
testcase_23 | AC | 20 ms
14,944 KB |
testcase_24 | AC | 21 ms
14,876 KB |
testcase_25 | AC | 31 ms
14,936 KB |
testcase_26 | AC | 35 ms
14,908 KB |
testcase_27 | AC | 21 ms
14,876 KB |
testcase_28 | AC | 27 ms
15,048 KB |
testcase_29 | AC | 35 ms
14,948 KB |
testcase_30 | AC | 40 ms
14,876 KB |
testcase_31 | AC | 31 ms
14,884 KB |
testcase_32 | AC | 49 ms
15,020 KB |
testcase_33 | AC | 47 ms
15,088 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; const int MOD9 = 998244353; template< int mod > struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int) (1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } friend ModInt operator+(const ModInt& lhs, const ModInt& rhs) { return ModInt(lhs) += rhs; } friend ModInt operator-(const ModInt& lhs, const ModInt& rhs) { return ModInt(lhs) -= rhs; } friend ModInt operator*(const ModInt& lhs, const ModInt& rhs) { return ModInt(lhs) *= rhs; } friend ModInt operator/(const ModInt& lhs, const ModInt& rhs) { return ModInt(lhs) /= rhs; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while(n > 0) { if(n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); } static int get_mod() { return mod; } }; template< typename T > struct Combination { vector< T > _fact, _rfact, _inv; Combination(ll sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) { _fact[0] = _rfact[sz] = _inv[0] = 1; for(ll i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i; _rfact[sz] /= _fact[sz]; for(ll i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1); for(ll i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1]; } inline T fact(ll k) const { return _fact[k]; } inline T rfact(ll k) const { return _rfact[k]; } inline T inv(ll k) const { return _inv[k]; } T P(ll n, ll r) const { if(r < 0 || n < r) return 0; return fact(n) * rfact(n - r); } T C(ll p, ll q) const { if(q < 0 || p < q) return 0; return fact(p) * rfact(q) * rfact(p - q); } T RC(ll p, ll q) const { if(q < 0 || p < q) return 0; return rfact(p) * fact(q) * fact(p - q); } T H(ll n, ll r) const { if(n < 0 || r < 0) return (0); return r == 0 ? 1 : C(n + r - 1, r); } //+1がm個、-1がn個で prefix sumが常にk以上 T catalan(ll m,ll n,ll k){ if(n>m-k)return 0; else return C(n+m,m)-C(n+m,n+k-1); } }; using modint = ModInt< MOD9 >;modint mpow(ll n, ll x){return modint(n).pow(x);}modint mpow(modint n, ll x){return n.pow(x);} //using modint=ld;modint mpow(ll n, ll x){return pow(n,x);}modint mpow(modint n, ll x){return pow(n,x);} using Comb=Combination<modint>; int main(){ int N, K; cin >> N >> K; assert(1 <= N <= 2e5); assert(0 <= K <= 2e5); Comb comb(1000005); modint ret = 0; for(int i = 0; i <= K; i++){ modint add = 0; add += comb.H(i,K+1-i)*comb.H(i,K-i)/max(1,i); ret += add * comb.H(2*K+1,N-(2*i-1)); } cout << ret << endl; }