結果

問題 No.1552 Simple Dice Game
ユーザー KudeKude
提出日時 2021-06-18 23:16:58
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 2,489 ms / 2,500 ms
コード長 668 bytes
コンパイル時間 1,458 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 92,916 KB
最終ジャッジ日時 2023-09-05 00:12:23
合計ジャッジ時間 31,048 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
91,708 KB
testcase_01 AC 97 ms
91,680 KB
testcase_02 AC 96 ms
91,624 KB
testcase_03 AC 2,146 ms
92,712 KB
testcase_04 AC 98 ms
91,556 KB
testcase_05 AC 95 ms
91,436 KB
testcase_06 AC 96 ms
91,852 KB
testcase_07 AC 95 ms
91,460 KB
testcase_08 AC 95 ms
91,556 KB
testcase_09 AC 1,870 ms
92,848 KB
testcase_10 AC 2,114 ms
92,772 KB
testcase_11 AC 2,197 ms
92,840 KB
testcase_12 AC 722 ms
92,904 KB
testcase_13 AC 1,834 ms
92,816 KB
testcase_14 AC 1,138 ms
92,876 KB
testcase_15 AC 1,345 ms
92,716 KB
testcase_16 AC 278 ms
92,788 KB
testcase_17 AC 406 ms
92,760 KB
testcase_18 AC 1,740 ms
92,648 KB
testcase_19 AC 2,433 ms
92,808 KB
testcase_20 AC 2,456 ms
92,756 KB
testcase_21 AC 2,457 ms
92,868 KB
testcase_22 AC 2,432 ms
92,528 KB
testcase_23 AC 2,489 ms
92,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

fact_range = 10**6
fact = [1] * (fact_range + 1)
for i in range(0, fact_range):
    fact[i+1] = fact[i] * (i + 1) % MOD

ifact = [1] * (fact_range + 1)
ifact[fact_range] = pow(fact[fact_range], MOD - 2, MOD)
for i in range(fact_range, 0, -1):
    ifact[i-1] = ifact[i] * i % MOD

def comb(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return fact[n] * ifact[n-k] % MOD * ifact[k] % MOD

n, m = map(int, input().split())
ans = 0
x = (1 + m) * pow(2, MOD - 2, MOD) % MOD
for d in range(m):
    ans += d * (m - d) * (pow(d + 1, n, MOD) - 2 * pow(d, n, MOD) + (pow(d - 1, n, MOD) if d - 1 >= 0 else 0)) * x * n
    ans %= MOD
print(ans)
0