結果
問題 | No.2141 Enumeratest |
ユーザー | dyktr_06 |
提出日時 | 2022-12-02 21:47:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 156 ms / 2,000 ms |
コード長 | 5,618 bytes |
コンパイル時間 | 2,035 ms |
コンパイル使用メモリ | 170,160 KB |
実行使用メモリ | 50,076 KB |
最終ジャッジ日時 | 2024-10-09 22:58:05 |
合計ジャッジ時間 | 4,906 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 14 ms
9,472 KB |
testcase_03 | AC | 60 ms
26,624 KB |
testcase_04 | AC | 156 ms
50,076 KB |
testcase_05 | AC | 66 ms
26,668 KB |
testcase_06 | AC | 2 ms
5,248 KB |
testcase_07 | AC | 6 ms
5,376 KB |
testcase_08 | AC | 19 ms
11,648 KB |
testcase_09 | AC | 13 ms
8,704 KB |
testcase_10 | AC | 31 ms
16,472 KB |
testcase_11 | AC | 54 ms
24,492 KB |
testcase_12 | AC | 4 ms
5,248 KB |
testcase_13 | AC | 12 ms
8,192 KB |
testcase_14 | AC | 52 ms
24,064 KB |
testcase_15 | AC | 29 ms
15,360 KB |
testcase_16 | AC | 36 ms
18,432 KB |
testcase_17 | AC | 80 ms
32,000 KB |
testcase_18 | AC | 73 ms
28,672 KB |
testcase_19 | AC | 122 ms
41,216 KB |
testcase_20 | AC | 73 ms
29,568 KB |
testcase_21 | AC | 82 ms
31,488 KB |
testcase_22 | AC | 53 ms
22,656 KB |
testcase_23 | AC | 30 ms
15,488 KB |
testcase_24 | AC | 70 ms
30,080 KB |
testcase_25 | AC | 18 ms
11,008 KB |
testcase_26 | AC | 60 ms
25,216 KB |
testcase_27 | AC | 74 ms
29,184 KB |
testcase_28 | AC | 91 ms
32,640 KB |
testcase_29 | AC | 43 ms
19,584 KB |
testcase_30 | AC | 118 ms
40,576 KB |
testcase_31 | AC | 73 ms
28,672 KB |
testcase_32 | AC | 95 ms
34,944 KB |
testcase_33 | AC | 62 ms
26,112 KB |
testcase_34 | AC | 93 ms
34,048 KB |
testcase_35 | AC | 7 ms
5,632 KB |
testcase_36 | AC | 88 ms
32,768 KB |
コンパイルメッセージ
main.cpp: In function 'void in(T& ...)': main.cpp:28:55: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 28 | template<class... T> void in(T&... a){ (cin >> ... >> a); } | ^ main.cpp: In function 'void out(const T&, const Ts& ...)': main.cpp:30:112: warning: fold-expressions only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 30 | template<class T, class... Ts> void out(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } | ^
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)(n); ++i) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; --i) #define ALL(a) a.begin(), a.end() #define Sort(a) sort(a.begin(), a.end()) #define RSort(a) sort(a.rbegin(), a.rend()) typedef long long int ll; typedef long double ld; typedef vector<int> vi; typedef vector<long long> vll; typedef vector<char> vc; typedef vector<string> vst; typedef vector<double> vd; typedef pair<long long, long long> P; const long long INF = 0x1fffffffffffffff; const long long MOD = 998244353; const long double PI = acos(-1); template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T, class U> inline T vin(T& vec, U n) { vec.resize(n); for(int i = 0; i < (int) n; ++i) cin >> vec[i]; return vec; } template<class T> inline void vout(T vec, string s = "\n"){ for(auto x : vec) cout << x << s; } template<class... T> void in(T&... a){ (cin >> ... >> a); } void out(){ cout << '\n'; } template<class T, class... Ts> void out(const T& a, const Ts&... b){ cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; } template<class T, class U> void inGraph(vector<vector<T>>& G, U n, U m, bool directed = false){ G.resize(n); for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; a--, b--; G[a].push_back(b); if(!directed) G[b].push_back(a); } } template <long long Modulus> struct ModInt{ long long val; constexpr ModInt(const long long &_val = 0) noexcept : val(_val) { normalize(); } void normalize(){ val = (val % Modulus + Modulus) % Modulus; } inline ModInt& operator+=(const ModInt& rhs) noexcept { if(val += rhs.val, val >= Modulus) val -= Modulus; return *this; } inline ModInt& operator-=(const ModInt& rhs) noexcept { if(val -= rhs.val, val < 0) val += Modulus; return *this; } inline ModInt& operator*=(const ModInt& rhs) noexcept { val = val * rhs.val % Modulus; return *this; } inline ModInt& operator/=(const ModInt& rhs) noexcept { val = val * inv(rhs.val).val % Modulus; return *this; } inline ModInt& operator++() noexcept { if(++val >= Modulus) val -= Modulus; return *this; } inline ModInt operator++(int) noexcept { ModInt t = val; if(++val >= Modulus) val -= Modulus; return t; } inline ModInt& operator--() noexcept { if(--val < 0) val += Modulus; return *this; } inline ModInt operator--(int) noexcept { ModInt t = val; if(--val < 0) val += Modulus; return t; } inline ModInt operator-() const noexcept { return (Modulus - val) % Modulus; } inline ModInt inv(void) const { return inv(val); } ModInt inv(const long long& n) const { long long a = n, b = Modulus, u = 1, v = 0; while(b){ long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= Modulus; if(u < 0) u += Modulus; return u; } friend inline ModInt operator+(const ModInt& lhs, const ModInt& rhs) noexcept { return ModInt(lhs) += rhs; } friend inline ModInt operator-(const ModInt& lhs, const ModInt& rhs) noexcept { return ModInt(lhs) -= rhs; } friend inline ModInt operator*(const ModInt& lhs, const ModInt& rhs) noexcept { return ModInt(lhs) *= rhs; } friend inline ModInt operator/(const ModInt& lhs, const ModInt& rhs) noexcept { return ModInt(lhs) /= rhs; } friend inline bool operator==(const ModInt& lhs, const ModInt& rhs) noexcept { return lhs.val == rhs.val; } friend inline bool operator!=(const ModInt& lhs, const ModInt& rhs) noexcept { return lhs.val != rhs.val; } friend inline istream& operator>>(istream& is, ModInt& x) noexcept { is >> x.val; x.normalize(); return is; } friend inline ostream& operator<<(ostream& os, const ModInt& x) noexcept { return os << x.val; } }; struct Combination{ vector<long long> memo, memoinv, inv; const long long mod; Combination(const int &N, const long long &m) : memo(N + 1), memoinv(N + 1), inv(N + 1), mod(m){ memo[0] = memo[1] = 1; memoinv[0] = memoinv[1] = 1; inv[1] = 1; for(int i = 2; i <= N; ++i){ memo[i] = memo[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (m / i) % mod; memoinv[i] = memoinv[i - 1] * inv[i] % mod; } } inline long long fact(const long long &n) const { return memo[n]; } inline long long factinv(const long long &n) const { return memoinv[n]; } inline long long ncr(const long long &n, const long long &r) const { if(n < r || r < 0) return 0; return (memo[n] * memoinv[r] % mod) * memoinv[n - r] % mod; } inline long long npr(const long long &n, const long long &r) const { if(n < r || r < 0) return 0; return (memo[n] % mod) * memoinv[n - r] % mod; } }; ll n, m; using mint = ModInt<998244353>; void input(){ in(n, m); } void solve(){ Combination comb(n + m, MOD); ll d = m / n; ll e = m % n; mint ans = 1; rep(i, n){ if(i < e){ ans *= comb.ncr(m, d + 1); m -= d + 1; }else{ ans *= comb.ncr(m, d); m -= d; } } out(ans); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); input(); solve(); }