QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#209166#6736. Alice and BobluhanningTL 0ms0kbC++14848b2023-10-10 11:01:062023-10-10 11:01:07

Judging History

你现在查看的是最新测评结果

  • [2023-10-10 11:01:07]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-10-10 11:01:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e7 + 10;
const int mod = 998244353;
int n, m, k;
string s1, s2;
int h[N], idx, ne[N];
vector<int> pa;
double a, b;
int infact[N];
int fact[N];

int qmi(int a,int k,int p)
{
	int res=1;
	while(k){
		if(k&1) res=res*a%p;
		a=a*a%p;
		k>>=1;
	}
	return res;
}


void solve() {
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n+1; i++) {
		
		if (n - i >= i - 1) {
			int t1=fact[n-i]%mod;
			int t2=fact[n-i]*infact[n-i-(i-1)]%mod;
			ans=(ans+(t1*t2)%mod)%mod;
		}
		
	}
	//cout<<fact[3]<<endl;
	cout << ans << endl;
}


signed main() {
	int t = 1;
	fact[0]=infact[0]=1;
	for(int i=1;i<N;i++)
	{
		fact[i]=fact[i-1]*i%mod;
		infact[i]=infact[i-1]*qmi(i,mod-2,mod)%mod;
	}
	//cin >> t;
	while (t--) {
		solve();
	}
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

1

output:

1

result: