QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#356263#6736. Alice and Bobstar_xiao#WA 1ms7748kbC++14973b2024-03-17 17:08:212024-03-17 17:08:22

Judging History

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

  • [2024-03-17 17:08:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7748kb
  • [2024-03-17 17:08:21]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

//int n;
const int N=1e7+10;
#define int long long 
const int mod=998244353;

int sum[N];
int fac[N],infac[N];
int n;

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

void init()
{
	fac[0]=infac[0]=1ll;
	for(int i=1;i<=n;i++)
	{
		fac[i]=fac[i-1]*i%mod;
		infac[i]=infac[i-1]*qmi(i,mod-2)%mod;
	}
}

int C(int a,int b)
{
	return fac[b]*infac[a]%mod*infac[b-a]%mod;
}


void solve()
{
	int ans=0;
	cin>>n;
	sum[0]=1ll;
	init();
	//cout<<C(3,2);
	for(int i=1;i<=n;i++)
	{
		//ans=ans*i%mod;
		sum[i]=sum[i-1]*i%mod;
		
	}
	//sum[0]=0;
	ans=(sum[n-1])%mod;
	for(int i=2;i<=n;i++)
	{
		ans=(ans+(C(i-1,n-i)%mod)*sum[i-1]%mod*sum[n-i]%mod)%mod;
		//cout<<ans<<'\n';
	}
	cout<<(ans+mod)%mod;
	
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7748kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5552kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 5616kb

input:

10

output:

346339639

result:

wrong answer 1st numbers differ - expected: '997920', found: '346339639'