SDUT热身赛D题

你最#讨厌#恶心#不想做#无语#next的01字符串

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e7 + 10;
const int mod = 998244353;
int n;
int ksm(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1)
			ans = ans * x % mod;
		y >>= 1;
		x = x * x % mod;
	}
	return ans;
}
int ni(int x) {
	return ksm(x, mod - 2);
}
int C(int x, int y) {
	int fz = 1, fm = 1, ans = 1;
	for (int i = 1; i <= x; i++) {
		fz = fz * i % mod;
	}
	for (int i = 1; i <= y; i++) {
		fm = fm * i % mod;
	}
	for (int i = 1; i <= x - y; i++) {
		ans = ans * i % mod;
	}
	int res = ((fz * ni(fm) % mod) * ni(ans) % mod);
	return res;
}
signed main() {
	cin >> n;
	int m = 2 * n;
	int x = m, y = n + 1;
	cout << C(x, y) << '\n';
}
posted @ 2024-07-05 17:45  ZhangDT  阅读(1)  评论(0编辑  收藏  举报