結果

問題 No.1552 Simple Dice Game
ユーザー chocoruskchocorusk
提出日時 2021-06-18 21:49:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 587 ms / 2,500 ms
コード長 1,212 bytes
コンパイル時間 3,275 ms
コンパイル使用メモリ 188,336 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-04 22:47:31
合計ジャッジ時間 11,033 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 585 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 448 ms
4,376 KB
testcase_10 AC 529 ms
4,376 KB
testcase_11 AC 532 ms
4,376 KB
testcase_12 AC 153 ms
4,376 KB
testcase_13 AC 446 ms
4,380 KB
testcase_14 AC 260 ms
4,376 KB
testcase_15 AC 329 ms
4,380 KB
testcase_16 AC 47 ms
4,376 KB
testcase_17 AC 75 ms
4,380 KB
testcase_18 AC 410 ms
4,380 KB
testcase_19 AC 586 ms
4,376 KB
testcase_20 AC 587 ms
4,376 KB
testcase_21 AC 584 ms
4,376 KB
testcase_22 AC 586 ms
4,376 KB
testcase_23 AC 587 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
int main()
{
    ll n;
    int m;
    cin>>n>>m;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    mint ans=0;
    ll s=(ll)m*(m+1)/2;
    for(int i=1; i<=m; i++){
        mint p=mint(i).pow(n);
        p*=mint((ll)i*(i+1)/2);
        ans+=p;
        p=(mint(i-1).pow(n-1))*mint(i);
        p*=mint((ll)i*(i+1)/2-i);
        ans-=p;
        p=(mint(m+1-i).pow(n-1))*mint(i);
        p*=mint(s);
        ans-=p;
        p=(mint(m-i).pow(n-1))*mint(i);
        p*=mint(s-i);
        ans+=p;
        s-=i;
    }
    ans*=mint(n);
    cout<<ans.val()<<endl;
    return 0;
}
0