結果
問題 | No.1321 塗るめた |
ユーザー |
![]() |
提出日時 | 2020-12-18 23:34:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 1,681 bytes |
コンパイル時間 | 858 ms |
コンパイル使用メモリ | 68,220 KB |
最終ジャッジ日時 | 2025-01-17 03:09:13 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 45 |
ソースコード
#include <iostream>using namespace std;class ModComb {long long *fact, *facti;const int mod;public:explicit ModComb(int n, int m) : mod(m) {fact = new long long[n+1];facti = new long long[n+1];fact[0] = 1; facti[0] = 1;for (int i = 1; i <= n; i++) fact[i] = (fact[i-1] * i) % m;// calc 1/n!long long &inv = facti[n], pw = fact[n];inv = 1;for (int e = mod-2; e > 0; e /= 2) {if (e&1) inv = inv * pw % mod;pw = pw * pw % mod;}for (int i = n-1; i > 0; i--) facti[i] = (facti[i+1] * (i+1)) % m;}~ModComb() {if (fact) delete[] fact;if (facti) delete[] facti;}long long getFact(int n) const {return fact[n];}long long getFactInv(int n) const {return facti[n];}long long getComb(int n, int k) const {if (n < 0 || k < 0 || k > n) return 0;return fact[n] * facti[k] % mod * facti[n-k] % mod;}long long getPerm(int n, int k) const {if (n < 0 || k < 0 || k > n) return 0;return fact[n] * facti[n-k] % mod;}};constexpr int M = 998244353;long long modexp(int x, long long e, int m) {long long ans = 1, p = x % m;while (e > 0) {if (e % 2 != 0) ans = (ans * p) % m;p = (p * p) % m;e >>= 1;}return ans;}int main() {int n, m, k; cin >> n >> m >> k;long long ans = 0;ModComb mc(2*n, M);for (int l = 0; l <= k; l++)ans += ((k - l) % 2 ? -1 : 1) * modexp(m+l, n, M) * mc.getComb(k, l) % M;cout << (ans % M * mc.getComb(m, k) % M + M) % M << endl;}