結果

問題 No.2670 Sum of Products of Interval Lengths
ユーザー 👑 ygussanyygussany
提出日時 2024-02-25 10:33:57
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 685 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 32,000 KB
実行使用メモリ 10,644 KB
最終ジャッジ日時 2024-02-25 10:34:29
合計ジャッジ時間 3,571 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast,unroll-loops")
#include <stdio.h>

const int Mod = 998244353;

long long solve_n_square(int n, long long m)
{
	int i, j, coeff[200001] = {};
	long long ans[200001] = {1};
	for (i = 0; i <= n && i < m; i++) {
		switch (i % 6) {
		case 0:
		case 1:
			coeff[i] = (m - i) % Mod;
			break;
		case 3:
		case 4:
			coeff[i] = (Mod - (m - i) % Mod) % Mod;
			break;
		}
	}
	for (i = 1; i <= n; i++) {
		for (j = 0; j < i; j++) ans[i] += ans[i-j-1] * coeff[j] % Mod;
		ans[i] %= Mod;
	}
	return ans[n];
}

int main()
{
	int n;
	long long m;
	scanf("%d %lld", &n, &m);
	printf("%lld\n", solve_n_square(n, m));
	fflush(stdout);
	return 0;
}
0