結果

問題 No.1552 Simple Dice Game
ユーザー gorugo30gorugo30
提出日時 2021-06-18 22:26:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,196 bytes
コンパイル時間 3,417 ms
コンパイル使用メモリ 197,956 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-04 23:37:19
合計ジャッジ時間 9,372 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define MOD 998244353
#define pb push_back
#define yes "Yes"
#define no "No"
#define ALL(x) (x).begin(), (x).end()
#define int long long 
template<class T> bool chmax(T &x, const T &y){if (x < y) {x = y; return true;} return false;}
template<class T> bool chmin(T &x, const T &y){if (x > y) {x = y; return true;} return false;}
template<class T> void print(T x){cout << x << endl;}

int modpow(int x, int n){
    int ret = 1;
    while (n > 0){
        if (n & 1){
            ret = (ret * x) % MOD;
        }
        n >>= 1;
        x = (x * x) % MOD;
    }
    return ret;
}
int s(int x){
    return x * (x + 1) / 2 % MOD;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;
    int ans = 0;
    for (int m = 1; m <= M; m++){
        int tmp = s(m) * modpow(m, N - 1) - s(m - 1) * modpow(m - 1, N - 1);
        tmp %= MOD;
        ans = (ans + m * tmp % MOD * N) % MOD;
        tmp = (s(M) - s(m - 1)) * modpow(M - m + 1, N - 1) - (s(M) - s(m)) * modpow(M - m, N - 1);
        tmp %= MOD;
        ans = (ans - m * tmp % MOD * N) % MOD;
    }
    if (ans < 0) ans += MOD;
    print(ans);
}
0