結果
問題 | No.2299 Antitypoglycemia |
ユーザー |
|
提出日時 | 2023-05-13 19:21:09 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 641 bytes |
コンパイル時間 | 5,214 ms |
コンパイル使用メモリ | 310,076 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-29 11:00:40 |
合計ジャッジ時間 | 5,401 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h>#if __has_include(<atcoder/all>)#include <atcoder/all>using namespace atcoder;#endif#define rep(i, n) for (int i = 0; i < (n); ++i)using namespace std;using mint = modint998244353;struct modfact {int n; vector<mint> d;modfact(): n(2), d({1,1}) {}mint operator()(int i) {while (n <= i) d.push_back(d.back()*n), ++n;return d[i];}mint operator[](int i) const { return d[i];}} facts;int main() {int n, a, b;cin >> n >> a >> b;mint ans = facts(n);ans -= facts(n-1)*2;if (a != b) ans += facts(n-2);cout << ans.val() << '\n';return 0;}