結果
問題 |
No.2023 Tiling is Fun
|
ユーザー |
![]() |
提出日時 | 2022-07-30 01:10:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 941 bytes |
コンパイル時間 | 1,538 ms |
コンパイル使用メモリ | 165,912 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 19:27:42 |
合計ジャッジ時間 | 2,518 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2022.07.30 01:10:27 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; ll powMod(ll k, ll n, ll mod) { ll x = 1; while (n > 0) { if (n & 1) { x = x * k % mod; } k = k * k % mod; n >>= 1; } return x; } ll comb(ll n, ll r, ll mod) { ll ret = 1; while (true) { if (r == 0) break; ll N = n % mod; ll R = r % mod; if (N < R) return 0; for (int i = 0; i < R; i++) { ret = ret * (N - i) % mod; } ll imul = 1; for (int i = 0; i < R; i++) { imul = imul * (i + 1) % mod; } ret = ret * powMod(imul, mod - 2, mod) % mod; n /= mod; r /= mod; } return ret; } int main() { int a,b;cin >> a >> b; cout << comb(a+b-2,a-1,998244353) << endl; return 0; }