結果

問題 No.1552 Simple Dice Game
ユーザー hongrockhongrock
提出日時 2021-06-18 21:37:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 164 ms / 2,500 ms
コード長 1,283 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 198,836 KB
実行使用メモリ 11,560 KB
最終ジャッジ日時 2023-09-04 22:34:24
合計ジャッジ時間 5,061 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,536 KB
testcase_01 AC 2 ms
5,568 KB
testcase_02 AC 2 ms
5,580 KB
testcase_03 AC 164 ms
11,340 KB
testcase_04 AC 2 ms
5,524 KB
testcase_05 AC 2 ms
5,796 KB
testcase_06 AC 2 ms
5,544 KB
testcase_07 AC 2 ms
5,524 KB
testcase_08 AC 2 ms
5,572 KB
testcase_09 AC 125 ms
10,600 KB
testcase_10 AC 148 ms
11,152 KB
testcase_11 AC 150 ms
11,100 KB
testcase_12 AC 44 ms
8,552 KB
testcase_13 AC 124 ms
10,596 KB
testcase_14 AC 73 ms
9,340 KB
testcase_15 AC 92 ms
9,604 KB
testcase_16 AC 15 ms
8,008 KB
testcase_17 AC 23 ms
8,136 KB
testcase_18 AC 115 ms
10,284 KB
testcase_19 AC 163 ms
11,560 KB
testcase_20 AC 164 ms
11,336 KB
testcase_21 AC 162 ms
11,412 KB
testcase_22 AC 163 ms
11,304 KB
testcase_23 AC 164 ms
11,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, a, n) for(int i=(a); i<(n); ++i)
#define per(i, a, n) for(int i=(a); i>(n); --i)
#define pb emplace_back
#define mp make_pair
#define clr(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(),(x).end()
#define lowbit(x) (x & -x)
#define fi first
#define se second
#define lson o<<1
#define rson o<<1|1
#define gmid l[o]+r[o]>>1

using LL = long long;
using ULL = unsigned long long;
using pii = pair<int,int>;
using PLL = pair<LL, LL>;
using UI = unsigned int;

const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1.0);

const int N = 5e5 + 10;
LL a[N], sum[N];
LL n;
int m;

LL pow_mod(LL x, LL p){
	LL s = 1;
	while(p){
		if(p & 1)	s = s * x % mod;
		x = x * x % mod;
		p >>= 1;
	}
	return s;
}

int main(){
	scanf("%lld %d", &n, &m);
	sum[0] = a[0] = 0;
	rep(i, 1, m + 1){
		sum[i] = (sum[i-1] + i) % mod;
		a[i] = pow_mod(i, n - 1);
	}

	LL ans = 0;

	rep(i, 1, m + 1){
		ans = ans + (sum[i] * a[i] % mod + mod - sum[i-1] * a[i-1] % mod) % mod * i % mod;
		ans = ans + ((sum[m] + mod - sum[i-1]) * a[m-i+1] % mod + mod - (sum[m] + mod - sum[i]) % mod * a[m-i]) % mod * (mod - i) % mod;
		ans = ans % mod;
	}
	printf("%lld\n", n % mod * ans % mod);

	
	return 0;
}
0