当前位置: 首页 > 工具软件 > Cayley > 使用案例 >

Biological Software Utilities(cayley定理)

百里承业
2023-12-01
//https://codeforces.com/group/MKpYqfAQQQ/contest/401639/problem/G
#include<bits/stdc++.h>
#include<unordered_map>
#include<array>
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const ll mod = 998244353;
const int N = 1e6 + 5;

ll n;

ll qpow(ll base, ll pow)
{
	ll ans = 1;
	while (pow)
	{
		if (pow & 1)
			ans = ans * base % mod;
		base = base * base % mod;
		pow >>= 1;
	}
	return ans;
}

void solve()
{
	cin >> n;
	if (n % 2)
	{
		cout << 0 << '\n';
		return;
	}
	ll ans = 1;
	for (int i = 1; i <= n / 2 - 2; i++)
		ans = ans * (n / 2) % mod;
	for (int i = 1; i <= n / 2 - 1; i++)
		ans = ans * 4 % mod;
	for (int i = 1; i <= n; i++)
		ans = ans * i % mod;
	for (int i = 1; i <= n / 2; i++)
		ans = ans * qpow(2, mod - 2) % mod;
	for (int i = 1; i <= n / 2; i++)
		ans = ans * qpow(i, mod - 2) % mod;
	cout << ans << '\n';
}

signed main()
{
	IOS;
	int t = 1;
	//cin >> t;
	while (t--)
		solve();
	return 0;
}

 类似资料: