QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#578621 | #1882. Drunkards | xzf_200906 | WA | 0ms | 3648kb | C++14 | 728b | 2024-09-20 20:28:56 | 2024-09-20 20:28:57 |
Judging History
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'