提出 #45509309


ソースコード 拡げる

#include<bits/stdc++.h>
#define LL long long
#define DB double
#define MOD 998244353
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T &b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T &b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
	int res = 1;
	while(k)
	{
		if(k & 1) Mul(res, x);
		k >>= 1, Sqr(x);
	}
	return res;
}
const int N = 3e7 + 5;
int fac[N], facinv[N];
void preprocess()
{
	fac[0] = facinv[0] = 1;
	for(int i = 1; i < N; ++i)
		fac[i] = mul(fac[i - 1], i);
	facinv[N - 1] = qwqmi(fac[N - 1]);
	for(int i = N - 2; i >= 1; --i)
		facinv[i] = mul(facinv[i + 1], i + 1);
}
int C(int n, int m)
{
	if(n < m) return 0;
	return mul(fac[n], mul(facinv[m], facinv[n - m]));
}
int n, m;
int F[N], G[N], ans;
int main()
{
	preprocess();
	scanf("%d %d", &n, &m);
	for(int i = 0; 3 * i <= m; ++i)
		F[3 * i] = C(n + i - 2, i);
	for(int i = 0; i <= n - 1; ++i)
		G[n + i - 1] = C(n - 1, i);
	for(int i = 1; i <= m; ++i)
		Inc(F[i], F[i - 1]);
	for(int i = 1; i <= m; ++i)
		Inc(F[i], F[i - 1]);
	for(int i = 0; i <= m; ++i)
		Inc(ans, mul(F[i], G[m - i]));
	printf("%d\n", ans);
	return 0;
}

提出情報

提出日時
問題 G - Count Sequences
ユーザ Schucking_Sattin
言語 C++ 20 (gcc 12.2)
得点 600
コード長 2076 Byte
結果 AC
実行時間 454 ms
メモリ 316432 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:61:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   61 |         scanf("%d %d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 2
AC × 49
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_smallNM_00.txt, 01_smallNM_01.txt, 01_smallNM_02.txt, 01_smallNM_03.txt, 01_smallNM_04.txt, 01_smallNM_05.txt, 01_smallNM_06.txt, 01_smallNM_07.txt, 01_smallNM_08.txt, 01_smallNM_09.txt, 01_smallNM_10.txt, 01_smallNM_11.txt, 02_smallN_00.txt, 02_smallN_01.txt, 02_smallN_02.txt, 02_smallN_03.txt, 02_smallN_04.txt, 02_smallN_05.txt, 02_smallN_06.txt, 03_rnd_00.txt, 03_rnd_01.txt, 03_rnd_02.txt, 03_rnd_03.txt, 03_rnd_04.txt, 03_rnd_05.txt, 03_rnd_06.txt, 03_rnd_07.txt, 04_max_00.txt, 04_max_01.txt, 04_max_02.txt, 04_max_03.txt, 04_max_04.txt, 04_max_05.txt, 04_max_06.txt, 04_max_07.txt, 04_max_08.txt, 04_max_09.txt, 04_max_10.txt, 04_max_11.txt, 04_max_12.txt, 04_max_13.txt, 04_max_14.txt, 04_max_15.txt, 04_max_16.txt, 04_max_17.txt, 04_max_18.txt, 04_max_19.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 328 ms 238172 KiB
00_sample_01.txt AC 417 ms 277028 KiB
01_smallNM_00.txt AC 328 ms 237960 KiB
01_smallNM_01.txt AC 328 ms 238284 KiB
01_smallNM_02.txt AC 328 ms 238088 KiB
01_smallNM_03.txt AC 328 ms 238160 KiB
01_smallNM_04.txt AC 328 ms 238088 KiB
01_smallNM_05.txt AC 328 ms 238224 KiB
01_smallNM_06.txt AC 328 ms 238072 KiB
01_smallNM_07.txt AC 328 ms 238040 KiB
01_smallNM_08.txt AC 328 ms 238048 KiB
01_smallNM_09.txt AC 328 ms 238232 KiB
01_smallNM_10.txt AC 328 ms 238160 KiB
01_smallNM_11.txt AC 328 ms 237964 KiB
02_smallN_00.txt AC 418 ms 277216 KiB
02_smallN_01.txt AC 417 ms 277248 KiB
02_smallN_02.txt AC 418 ms 277244 KiB
02_smallN_03.txt AC 417 ms 277248 KiB
02_smallN_04.txt AC 418 ms 277292 KiB
02_smallN_05.txt AC 418 ms 277152 KiB
02_smallN_06.txt AC 417 ms 277236 KiB
03_rnd_00.txt AC 398 ms 285520 KiB
03_rnd_01.txt AC 369 ms 262580 KiB
03_rnd_02.txt AC 364 ms 270396 KiB
03_rnd_03.txt AC 426 ms 294988 KiB
03_rnd_04.txt AC 369 ms 266708 KiB
03_rnd_05.txt AC 420 ms 285868 KiB
03_rnd_06.txt AC 376 ms 277688 KiB
03_rnd_07.txt AC 363 ms 258928 KiB
04_max_00.txt AC 453 ms 316292 KiB
04_max_01.txt AC 434 ms 296688 KiB
04_max_02.txt AC 425 ms 286860 KiB
04_max_03.txt AC 422 ms 281916 KiB
04_max_04.txt AC 420 ms 279548 KiB
04_max_05.txt AC 454 ms 316364 KiB
04_max_06.txt AC 453 ms 316176 KiB
04_max_07.txt AC 453 ms 316172 KiB
04_max_08.txt AC 452 ms 316308 KiB
04_max_09.txt AC 453 ms 316204 KiB
04_max_10.txt AC 452 ms 316180 KiB
04_max_11.txt AC 453 ms 316176 KiB
04_max_12.txt AC 453 ms 316236 KiB
04_max_13.txt AC 453 ms 316164 KiB
04_max_14.txt AC 453 ms 316312 KiB
04_max_15.txt AC 453 ms 316096 KiB
04_max_16.txt AC 453 ms 316432 KiB
04_max_17.txt AC 452 ms 316092 KiB
04_max_18.txt AC 453 ms 316216 KiB
04_max_19.txt AC 453 ms 316312 KiB