QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#364584#6736. Alice and BobAtmizz#WA 0ms5656kbC++20971b2024-03-24 15:26:082024-03-24 15:26:09

Judging History

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

  • [2024-03-24 15:26:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5656kb
  • [2024-03-24 15:26:08]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
const int mod = 998244353;
typedef long long LL;
#define int long long
const int N = 1e7 + 20;
const int M = 1e7;

LL fac[N], inFac[N];

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

LL C(LL n, LL m) {
	return fac[n] * inFac[m] % mod * inFac[n-m] % mod;
}

signed main()
{
    int n;
    cin >> n;
    fac[0] = 1;
    for(int i = 1; i <= n; ++ i) {
    	fac[i] = fac[i-1] * i % mod;
    }
    inFac[n] = qmi(fac[n], mod - 2);
    for(int i = n - 1; i >= 0; -- i) {
    	inFac[i] = inFac[i+1] * (i + 1) % mod;
    }
    vector<LL> s(n+10);
    s[0]=1;
    for(int i=1;i<=n;i++) s[i]=s[i-1]*i%mod;
    int sum=0;
    for(int x=1;x<=n;x++){
        sum=(sum+C(n-x,x-1)*s[n-x]%mod*s[x-1]%mod)%mod;
    }
    while(sum < 0) {
    	sum += mod;
    }
    cout<<(sum+mod)%mod<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5656kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 5644kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 5656kb

input:

10

output:

823950739

result:

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