結果

問題 No.1552 Simple Dice Game
ユーザー 👑 NachiaNachia
提出日時 2021-06-18 21:39:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 438 ms / 2,500 ms
コード長 800 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 75,056 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-04 22:35:21
合計ジャッジ時間 6,692 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 431 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 343 ms
4,380 KB
testcase_10 AC 393 ms
4,376 KB
testcase_11 AC 399 ms
4,380 KB
testcase_12 AC 115 ms
4,376 KB
testcase_13 AC 338 ms
4,380 KB
testcase_14 AC 194 ms
4,376 KB
testcase_15 AC 248 ms
4,380 KB
testcase_16 AC 36 ms
4,376 KB
testcase_17 AC 56 ms
4,376 KB
testcase_18 AC 306 ms
4,376 KB
testcase_19 AC 436 ms
4,380 KB
testcase_20 AC 435 ms
4,380 KB
testcase_21 AC 437 ms
4,376 KB
testcase_22 AC 438 ms
4,376 KB
testcase_23 AC 436 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
0