結果

問題 No.1552 Simple Dice Game
ユーザー 👑 NachiaNachia
提出日時 2021-06-18 21:39:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 562 ms / 2,500 ms
コード長 800 bytes
コンパイル時間 1,168 ms
コンパイル使用メモリ 74,352 KB
最終ジャッジ日時 2025-01-22 09:04:18
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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