結果

問題 No.1552 Simple Dice Game
ユーザー 00 Sakuda00 Sakuda
提出日時 2024-04-02 17:41:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,500 ms
コード長 542 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 205,656 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-02 17:41:33
合計ジャッジ時間 5,176 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 138 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 107 ms
6,676 KB
testcase_10 AC 126 ms
6,676 KB
testcase_11 AC 128 ms
6,676 KB
testcase_12 AC 38 ms
6,676 KB
testcase_13 AC 109 ms
6,676 KB
testcase_14 AC 64 ms
6,676 KB
testcase_15 AC 80 ms
6,676 KB
testcase_16 AC 13 ms
6,676 KB
testcase_17 AC 19 ms
6,676 KB
testcase_18 AC 97 ms
6,676 KB
testcase_19 AC 140 ms
6,676 KB
testcase_20 AC 141 ms
6,676 KB
testcase_21 AC 140 ms
6,676 KB
testcase_22 AC 143 ms
6,676 KB
testcase_23 AC 141 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace atcoder;
using namespace std;
using ll = long long;
using mint = modint998244353;
ll inf = 1e9;
int main() {
	ll N, M;cin >> N >> M;
	vector<mint> POW(M + 1, 0);
	for (ll i = 1;i <= M;i++) POW[i] = mint(i).pow(N);
	mint ans = 0;
	for (ll k = 1;k <= M;k++) {
		mint d = POW[k] - POW[k - 1];
		d *= mint(k);
		ans += d;
		d = POW[M - k + 1] - POW[M - k];
		d *= mint(k);
		ans -= d;
	}
	ans *= mint(N);
	ans *= mint(M + 1);
	ans *= mint(2).inv();
	cout << ans.val() << endl;
}
0