結果

問題 No.2023 Tiling is Fun
ユーザー atjh16atjh16
提出日時 2022-08-12 09:44:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 3,733 ms
コンパイル使用メモリ 201,084 KB
実行使用メモリ 6,748 KB
最終ジャッジ日時 2023-10-23 19:56:29
合計ジャッジ時間 3,585 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,676 KB
testcase_01 AC 22 ms
6,344 KB
testcase_02 AC 12 ms
6,156 KB
testcase_03 AC 13 ms
6,188 KB
testcase_04 AC 3 ms
5,732 KB
testcase_05 AC 12 ms
6,140 KB
testcase_06 AC 13 ms
6,200 KB
testcase_07 AC 26 ms
6,364 KB
testcase_08 AC 18 ms
6,344 KB
testcase_09 AC 24 ms
6,344 KB
testcase_10 AC 23 ms
6,344 KB
testcase_11 AC 2 ms
5,676 KB
testcase_12 AC 2 ms
5,676 KB
testcase_13 AC 2 ms
5,676 KB
testcase_14 AC 19 ms
6,344 KB
testcase_15 AC 18 ms
6,344 KB
testcase_16 AC 18 ms
6,344 KB
testcase_17 AC 34 ms
6,748 KB
testcase_18 AC 34 ms
6,748 KB
testcase_19 AC 25 ms
6,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long a, b;
const long long M = 998244353;
long long p[200001], q[200001];

long long powm(long long a, long long b) {
    long long u = 1, v = a;

    while (b > 0) {
        if (b & 1)
            u = u * v % M;

        b >>= 1;
        v = v * v % M;
    }

    return u;
}

int main() {    
    cin >> a >> b;

    p[0] = 1;
    q[0] = 1;

    for (int i = 1; i < a + b; i++) {
        p[i] = p[i - 1] * i % M;
        q[i] = powm(p[i], M - 2);
    }

    cout << p[a + b - 2] * q[b - 1] % M * q[a - 1] % M << endl;
}
0