結果

問題 No.1321 塗るめた
ユーザー trineutrontrineutron
提出日時 2020-12-18 11:34:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 206,040 KB
実行使用メモリ 5,180 KB
最終ジャッジ日時 2023-10-21 07:57:59
合計ジャッジ時間 4,406 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 25 ms
4,404 KB
testcase_13 AC 45 ms
4,932 KB
testcase_14 AC 15 ms
4,348 KB
testcase_15 AC 16 ms
4,348 KB
testcase_16 AC 22 ms
4,404 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 29 ms
4,932 KB
testcase_19 AC 11 ms
4,348 KB
testcase_20 AC 14 ms
4,348 KB
testcase_21 AC 35 ms
4,932 KB
testcase_22 AC 35 ms
5,180 KB
testcase_23 AC 32 ms
5,180 KB
testcase_24 AC 35 ms
5,180 KB
testcase_25 AC 30 ms
5,180 KB
testcase_26 AC 31 ms
5,180 KB
testcase_27 AC 40 ms
5,180 KB
testcase_28 AC 38 ms
5,180 KB
testcase_29 AC 39 ms
5,180 KB
testcase_30 AC 30 ms
5,180 KB
testcase_31 AC 48 ms
5,180 KB
testcase_32 AC 25 ms
4,404 KB
testcase_33 AC 13 ms
4,348 KB
testcase_34 AC 19 ms
4,404 KB
testcase_35 AC 12 ms
4,348 KB
testcase_36 AC 52 ms
5,180 KB
testcase_37 AC 46 ms
5,180 KB
testcase_38 AC 42 ms
5,180 KB
testcase_39 AC 45 ms
5,180 KB
testcase_40 AC 43 ms
5,180 KB
testcase_41 AC 45 ms
5,180 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 26 ms
4,404 KB
testcase_44 AC 13 ms
4,348 KB
testcase_45 AC 19 ms
4,404 KB
testcase_46 AC 6 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int64_t mod = 998244353;

vector<int64_t> fact, inv;

int64_t power(int64_t n, int64_t k) {
    if (k == 0) return 1;
    int64_t res = power(n * n % mod, k / 2);
    if (k % 2) res = res * n % mod;
    return res;
}

void init(int64_t n) {
    fact.push_back(1);
    inv.push_back(1);
    for (int i = 1; i <= n; i++) {
        fact.push_back(i * fact.back() % mod);
        inv.push_back(power(fact.back(), mod - 2));
    }
}

int64_t ncr(int64_t n, int64_t r) {
    if (r < 0 or n < r) return 0;
    return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

int main() {
    int64_t n, m, k;
    cin >> n >> m >> k;
    init(n);
    int64_t ans = 0;
    for (int64_t i = 0; i < k; i++) {
        int64_t d = (power(k - i + m, n) - power(m, n)) * ncr(m, k - i) % mod * ncr(m - k + i, i) % mod;
        if (i % 2 == 0) {
            ans += d;
        } else {
            ans -= d;
        }
    }
    cout << (ans % mod + mod) % mod << endl;
}
0