QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578621#1882. Drunkardsxzf_200906WA 0ms3648kbC++14728b2024-09-20 20:28:562024-09-20 20:28:57

Judging History

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

  • [2024-09-20 20:28:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3648kb
  • [2024-09-20 20:28:56]
  • 提交

answer

#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int mod=998244353;
int qp(int a,int b){
	int ret=1;
	while(b){
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ret;
}
int f[5005][10005],a[5005];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,p,pi;
	cin>>n>>p;
	p=1ll*p*qp(100,mod-2)%mod,pi=(1-p+mod)%mod;
	f[0][n]=1;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		f[i][n]=1;
	}
	for(int i=1;i<=n;i++)
	for(int j=0;j<=2*n;j++){
		if(j==n) continue;
		f[i][j]=(1ll*f[i-1][j+(a[n-i]==-1?1:-1)]*pi+1ll*f[i-1][j]*p)%mod;
	}
	int ans=0;
	for(int i=0;i<=2*n;i++) ans=(ans+f[n][i])%mod;
	cout<<1ll*ans*qp(2*n+1,mod-2)%mod;
	return 0;
}

详细

Test #1:

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

input:

2 28
1 1

output:

702764025

result:

ok 1 number(s): "702764025"

Test #2:

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

input:

5 50
-1 1 -1 -1 -1

output:

680621150

result:

wrong answer 1st numbers differ - expected: '17015529', found: '680621150'