結果
| 問題 | No.3394 Big Binom |
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2025-12-02 10:30:17 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,499 ms / 2,000 ms |
| コード長 | 1,110 bytes |
| 記録 | |
| コンパイル時間 | 3,149 ms |
| コンパイル使用メモリ | 278,628 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-02 10:30:34 |
| 合計ジャッジ時間 | 13,036 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; }
bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; }
#include <atcoder/modint>
using mint = atcoder::modint998244353;
const mint fac_memo[] = {
1, 808258749, 117153405, 761699708, 573994984, 62402409, 511621808, 242726978, 887890124, 875880304
};
mint fac(int n) {
int m = n / (int)1e8;
mint res = fac_memo[m];
m *= (int)1e8;
while (m < n) {
res *= ++m;
}
return res;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, K;
cin >> N >> K;
if (N < mint::mod()) {
cout << (fac(N) * (fac(N - K) * fac(K)).inv()).val() << endl;
} else {
if (K < mint::mod() && N - K < mint::mod()) {
cout << 0 << '\n';
} else {
K = min(K, N - K);
mint a = 1, b = 1;
for (int i = 0; i < K; i++) {
a *= N - i;
b *= i + 1;
}
cout << (a / b).val() << endl;
}
}
}
nonon