結果
問題 |
No.1321 塗るめた
|
ユーザー |
|
提出日時 | 2025-01-02 19:00:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 838 bytes |
コンパイル時間 | 2,096 ms |
コンパイル使用メモリ | 192,092 KB |
最終ジャッジ日時 | 2025-02-26 17:24:11 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 45 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d%d%d", &n, &m, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using LL = long long; const int N = 1e5 + 7; const int MOD = 998244353; int n, m, k, fac[N], ifc[N]; int pow(int x, int y) { int ret = 1; while(y) { if(y & 1) ret = 1LL * ret * x % MOD; x = 1LL * x * x % MOD; y >>= 1; } return ret; } int com(int x, int y) { return 1LL * fac[x] * ifc[y] % MOD * ifc[x - y] % MOD; } int main() { fac[0] = 1; for(int i = 1; i < N; ++i) fac[i] = 1LL * fac[i - 1] * i % MOD; ifc[N - 1] = pow(fac[N - 1], MOD - 2); for(int i = N - 2; i >= 0; --i) ifc[i] = 1LL * ifc[i + 1] * (i + 1) % MOD; scanf("%d%d%d", &n, &m, &k); int ans = 0; for(int i = 0; i <= k; ++i) ans = (ans + (i & 1 ? -1LL : 1LL) * com(k, i) * pow(m + k - i, n)) % MOD; ans = 1LL * (ans + MOD) * com(m, k) % MOD; printf("%d\n", ans); return 0; }