結果

問題 No.2023 Tiling is Fun
ユーザー atjh16atjh16
提出日時 2022-08-12 09:42:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 2,225 ms
コンパイル使用メモリ 201,304 KB
実行使用メモリ 6,736 KB
最終ジャッジ日時 2023-10-23 19:54:59
合計ジャッジ時間 4,087 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,664 KB
testcase_01 AC 24 ms
6,332 KB
testcase_02 AC 13 ms
6,144 KB
testcase_03 AC 14 ms
6,176 KB
testcase_04 AC 3 ms
5,720 KB
testcase_05 AC 13 ms
6,128 KB
testcase_06 AC 14 ms
6,188 KB
testcase_07 AC 29 ms
6,352 KB
testcase_08 AC 19 ms
6,332 KB
testcase_09 AC 25 ms
6,332 KB
testcase_10 AC 25 ms
6,332 KB
testcase_11 AC 2 ms
5,664 KB
testcase_12 AC 2 ms
5,664 KB
testcase_13 AC 2 ms
5,664 KB
testcase_14 AC 20 ms
6,332 KB
testcase_15 AC 20 ms
6,332 KB
testcase_16 AC 20 ms
6,332 KB
testcase_17 AC 38 ms
6,736 KB
testcase_18 AC 38 ms
6,736 KB
testcase_19 AC 27 ms
6,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long a, b, m;
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);
    }

    for (int i = 0; i < b; i++)
        m = (m + p[a - 2 + i] * q[i] % M * q[a - 2] % M) % M;

    cout << m << endl;
}
0