結果
問題 | No.1552 Simple Dice Game |
ユーザー |
|
提出日時 | 2021-06-18 23:39:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 428 ms / 2,500 ms |
コード長 | 799 bytes |
コンパイル時間 | 601 ms |
コンパイル使用メモリ | 71,668 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-22 21:35:30 |
合計ジャッジ時間 | 6,455 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include <iostream>#include <vector>#include <atcoder/modint>using namespace std;using ll = long long;using ull = unsigned long long;#define rep(i,n) for(int i=0; i<(n); i++)using mll = atcoder::modint998244353;void testcase(){ull N,M; cin >> N >> M;mll ans = 0;for(ull minA = 1; minA <= M; minA++){mll w = M - minA + 1;mll x = mll(M*(M+1)/2 - (minA-1)*minA/2) / w;ans -= w.pow(N) * x * N;}ans += mll(M).pow(N) * (M*(M+1)/2) * N;for(ull maxA = 1; maxA < M; maxA++){mll w = maxA;mll x = mll(maxA*(maxA+1)/2) / w;ans -= w.pow(N) * x * N;}cout << ans.val() << "\n";}int main(){testcase();return 0;}struct ios_do_not_sync{ios_do_not_sync(){ios::sync_with_stdio(false);cin.tie(nullptr);}} ios_do_not_sync_inst;