QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#372930#6736. Alice and Bobteam129WA 835ms125976kbC++141.1kb2024-03-31 21:02:262024-03-31 21:02:26

Judging History

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

  • [2024-03-31 21:02:26]
  • 评测
  • 测评结果:WA
  • 用时:835ms
  • 内存:125976kb
  • [2024-03-31 21:02:26]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<map>
#include<string>
#include<iomanip>
#include<climits>
#include <sstream>
#include<functional>
#include <unordered_map>
#include<array>
using namespace std;
using ll = long long;
ll t, n, k, a, b;
const ll N = 1e7+10;
const ll MOD = 998244353;
ll fac[N], ifac[N];
ll quickPower(ll a, ll b, ll mod = MOD) {
	ll ans = 1, base = a;
	while (b > 0) {
		if (b & 1)
			(ans *= base) %= mod;

		(base *= base) %= mod;
		b >>= 1;
	}
	return ans;
}
ll fpm(ll x) //费马小定理
{
	return quickPower(x, MOD - 2);
}

int main()
{
	ll n;
	cin >> n;
	fac[0] = 1;
	for (int i = 1; i <= n ; i++) {
		fac[i] = fac[i - 1] * i %MOD;
		ifac[i] = fpm(fac[i]);
	}
	ll sum = 0;
	for (int i = n/2; i <= n - 2; i++) {
		ll N = n - 1 - i;
		ll M = i;
		sum = (sum + fac[M] * ifac[M - N] % MOD * fac[M] % MOD) % MOD;
	}
	sum = (sum + fac[n - 1]) % MOD;
	cout << sum;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

10

output:

997920

result:

ok 1 number(s): "997920"

Test #4:

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

input:

100

output:

188898954

result:

ok 1 number(s): "188898954"

Test #5:

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

input:

4

output:

10

result:

ok 1 number(s): "10"

Test #6:

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

input:

8

output:

12336

result:

ok 1 number(s): "12336"

Test #7:

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

input:

16

output:

373118483

result:

ok 1 number(s): "373118483"

Test #8:

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

input:

32

output:

314585464

result:

ok 1 number(s): "314585464"

Test #9:

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

input:

64

output:

627827331

result:

ok 1 number(s): "627827331"

Test #10:

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

input:

128

output:

828497685

result:

ok 1 number(s): "828497685"

Test #11:

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

input:

256

output:

65697890

result:

ok 1 number(s): "65697890"

Test #12:

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

input:

512

output:

854187619

result:

ok 1 number(s): "854187619"

Test #13:

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

input:

1024

output:

513823539

result:

ok 1 number(s): "513823539"

Test #14:

score: 0
Accepted
time: 149ms
memory: 30652kb

input:

1361956

output:

617368199

result:

ok 1 number(s): "617368199"

Test #15:

score: -100
Wrong Answer
time: 835ms
memory: 125976kb

input:

7579013

output:

693151411

result:

wrong answer 1st numbers differ - expected: '827172636', found: '693151411'