結果

問題 No.1886 Sum of Slide Max
ユーザー 👑 ygussanyygussany
提出日時 2022-03-06 10:37:09
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 1,146 ms
コンパイル使用メモリ 29,800 KB
実行使用メモリ 4,964 KB
最終ジャッジ日時 2023-09-28 00:54:59
合計ジャッジ時間 3,265 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 21 ms
4,740 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 17 ms
4,380 KB
testcase_08 AC 24 ms
4,944 KB
testcase_09 AC 24 ms
4,964 KB
testcase_10 AC 23 ms
4,924 KB
testcase_11 AC 23 ms
4,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 998244353;
long long fact[200001], fact_inv[200001];

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

long long combination(int n, int k)
{
	if (k < 0 || n < k) return 0;
	return fact[n] * fact_inv[k] % Mod * fact_inv[n-k] % Mod;
}

int main()
{
	int N;
	scanf("%d", &N);
	
	int i, k;
	long long max;
	for (i = 1, fact[0] = 1; i <= N; i++) fact[i] = fact[i-1] * i % Mod;
	for (i = N - 1, fact_inv[N] = div_mod(1, fact[N], Mod); i >= 0; i--) fact_inv[i] = fact_inv[i+1] * (i + 1) % Mod;
	for (k = 1, max = fact[N] * N % Mod; k < N; k++) printf("%lld\n", (max - fact[k] * fact[N-k] % Mod * combination(N, k + 1) % Mod + Mod) * (N - k + 1) % Mod);
	printf("%lld\n", max);
	fflush(stdout);
	return 0;
}
0