結果

問題 No.2511 Mountain Sequence
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-10-20 22:26:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 202,092 KB
実行使用メモリ 9,892 KB
最終ジャッジ日時 2023-10-20 22:26:59
合計ジャッジ時間 3,427 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,700 KB
testcase_01 AC 2 ms
5,700 KB
testcase_02 AC 7 ms
8,704 KB
testcase_03 AC 4 ms
7,856 KB
testcase_04 AC 4 ms
7,856 KB
testcase_05 AC 5 ms
8,116 KB
testcase_06 AC 6 ms
8,648 KB
testcase_07 AC 8 ms
9,200 KB
testcase_08 AC 4 ms
7,856 KB
testcase_09 AC 4 ms
7,856 KB
testcase_10 AC 8 ms
9,544 KB
testcase_11 AC 9 ms
9,732 KB
testcase_12 AC 2 ms
5,700 KB
testcase_13 AC 9 ms
9,892 KB
testcase_14 AC 9 ms
9,748 KB
testcase_15 AC 9 ms
9,860 KB
testcase_16 AC 9 ms
9,828 KB
testcase_17 AC 9 ms
9,800 KB
testcase_18 AC 9 ms
9,744 KB
testcase_19 AC 9 ms
9,760 KB
testcase_20 AC 9 ms
9,864 KB
testcase_21 AC 9 ms
9,772 KB
testcase_22 AC 9 ms
9,824 KB
testcase_23 AC 4 ms
7,856 KB
testcase_24 AC 5 ms
7,940 KB
testcase_25 AC 9 ms
9,820 KB
testcase_26 AC 4 ms
7,856 KB
testcase_27 AC 6 ms
8,664 KB
testcase_28 AC 2 ms
5,700 KB
testcase_29 AC 9 ms
9,892 KB
testcase_30 AC 9 ms
9,892 KB
testcase_31 AC 9 ms
9,892 KB
testcase_32 AC 10 ms
9,892 KB
testcase_33 AC 9 ms
9,892 KB
testcase_34 AC 9 ms
9,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll const m = 998244353;
ll mpow(ll a, ll n) {
	ll ret = 1;
	while (n) {
		if (n & 1) ret = (ret * a) % m;
		n >>= 1;
		a = (a * a) % m;
	}
	return ret;
}
int main() {
	int N, M;
	cin >> N >> M;
	ll kai[400040], fkai[400040];
	kai[0] = 1;
	for (int i = 1; i <= M * 2; i ++) {
		kai[i] = (kai[i - 1] * i) % m;
	}
	fkai[M * 2] = mpow(kai[M * 2], m - 2);
	for (int i = M * 2; i > 0; i --) {
		fkai[i - 1] = (fkai[i] * i) % m;
	}
	ll ans = 0;
	auto comb = [&](int n, int r) -> ll {
		if (r < 0 || n < r) return 0ll;
		ll ret = (kai[n] * fkai[r]) % m;
		ret = (ret * fkai[n - r]) % m;
		return ret;
	};
	for (int x = 1; x <= M; x ++) {
		int n = (x - 1) * 2;
		ans += comb(n, N - 1);
		ans %= m;
	}
	cout << ans << endl;
}
0