結果
問題 | No.2141 Enumeratest |
ユーザー |
![]() |
提出日時 | 2024-04-29 23:25:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 911 bytes |
コンパイル時間 | 1,861 ms |
コンパイル使用メモリ | 196,864 KB |
最終ジャッジ日時 | 2025-02-21 09:47:59 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using mint = atcoder::modint998244353; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } mint fact[1 << 20], inv[1 << 20]; mint nCr(int n, int r) { if (r < 0 || r > n) return 0; return fact[n] * inv[r] * inv[n - r]; } void init() { fact[0] = 1; for (int i = 1; i < (1 << 20); i++) { fact[i] = fact[i - 1] * i; } inv[(1 << 20) - 1] = fact[(1 << 20) - 1].inv(); for (int i = (1 << 20) - 2; i >= 0; i--) { inv[i] = inv[i + 1] * (i + 1); } } int main() { fast_io(); init(); int n, m; cin >> n >> m; vector<int> a(n, m / n); for (int i = 0; i < m % n; i++) { a[i]++; } mint ans = 1; int su = 0; for (int i = 0; i < n; i++) { ans *= nCr(m - su, a[i]); su += a[i]; } cout << ans.val() << endl; }