QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#204399#6736. Alice and BobkiwiHM#WA 1ms5860kbC++14842b2023-10-07 11:05:472023-10-07 11:05:47

Judging History

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

  • [2023-10-07 11:05:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5860kb
  • [2023-10-07 11:05:47]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e7 + 5;
const int INF = 998244353;

int n;
int fac[maxn], ifac[maxn];

inline int qpow(int x, int y){
	int ret = 1;
	for(; y; y >>= 1){
		if(y & 1) ret = 1ll * ret * x % INF;
		x = 1ll * x * x % INF;
	}
	return ret;
}

inline int binom(int x, int y){
	if(x > y) return 0;
	return 1ll * fac[x] * ifac[y] % INF * ifac[x - y] % INF;
}

int main(){
	scanf("%d", &n);
	fac[0] = 1; for(int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % INF;
	ifac[n] = qpow(fac[n], INF - 2); for(int i = n - 1; i >= 0; --i) ifac[i] = 1ll * ifac[i + 1] * (i + 1) % INF;
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		int res = 1ll * fac[n - i] * ifac[(n - i) - (i - 1)] % INF * fac[n - i] % INF;
		ans = (ans + res) % INF;
	}
	printf("%d\n", ans);
	return 0;
}

詳細信息

Test #1:

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

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

10

output:

997920

result:

ok 1 number(s): "997920"

Test #4:

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

input:

100

output:

686877341

result:

wrong answer 1st numbers differ - expected: '188898954', found: '686877341'