QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#488614 | #8815. Space Station | zyxawa | WA | 1ms | 3888kb | C++14 | 672b | 2024-07-24 11:59:28 | 2024-07-24 11:59:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,s,w,a[101];
ll ans,dp[101][20001],c[101][101];
const int mod=998244353;
ll inv(ll a){
ll s=1;
for(ll b=mod-2;b;b>>=1,a=a*a%mod) if(b&1) s=s*a%mod;
return s;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i<=n;i++) dp[0][0]=c[i][0]=1;
for(int i=1;i<=n;i++){
scanf("%d",&w),s+=w;
for(int j=i;j>=1;j--) for(int k=s;k>=w;k--) (dp[j][k]+=dp[j-1][k-w])%=mod;
for(int j=1;j<=i;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
}
for(int i=0;i<n;i++) for(int j=0;j<s;j++) (ans+=dp[i][j]*inv(c[n][i])%mod*(m>(s-j)/(n-i)?(s-j)*inv(n-i):m))%=mod;
printf("%lld",ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3888kb
input:
3 3 2 3 4
output:
499122185
result:
ok 1 number(s): "499122185"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
5 1 10 20 30 40 50
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
1 9 37
output:
9
result:
ok 1 number(s): "9"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
5 5 24 41 29 6 40
output:
25
result:
ok 1 number(s): "25"
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3828kb
input:
10 34 91 86 1 14 98 13 85 64 91 20
output:
763359361
result:
wrong answer 1st numbers differ - expected: '707882334', found: '763359361'