QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#799665#9839. Selection Sort Countrotcar07WA 1ms5720kbC++23645b2024-12-05 16:56:202024-12-05 16:56:21

Judging History

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

  • [2024-12-05 16:56:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5720kb
  • [2024-12-05 16:56:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
constexpr int maxn=2e5+5;
typedef long long ll;
constexpr ll mod=998244353;
ll fac[maxn],inv[maxn];
ll qpow(ll a,int b){
	ll ans=1;
	while(b){
		if(b&1) ans=ans*a%mod;
		a=a*a%mod,b>>=1;
	}
	return ans;
}int a[maxn];
int main(){
	std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<n;i++) cin>>a[i];
	for(int i=fac[0]=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=qpow(fac[n],mod-2);
	for(int i=n;i>=1;i--) inv[i-1]=inv[i]*i%mod;
	ll ans=1;
	for(int i=1;i<n;i++) ans=ans*fac[a[i]+1]%mod*inv[a[i+1]]%mod*inv[a[i]+1-a[i+1]]%mod;
	cout<<ans<<'\n';
}

详细

Test #1:

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

input:

3
1 1

output:

2

result:

ok single line: '2'

Test #2:

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

input:

6
0 1 1 1 0

output:

4

result:

ok single line: '4'

Test #3:

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

input:

6
0 1 2 1 1

output:

6

result:

ok single line: '6'

Test #4:

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

input:

8
3 3 2 1 2 1 1

output:

432

result:

wrong answer 1st lines differ - expected: '24', found: '432'