QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#488754 | #8815. Space Station | thomaswmy | WA | 52ms | 6984kb | C++14 | 954b | 2024-07-24 15:08:35 | 2024-07-24 15:08:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=110;
const int M=1e4+10;
const int Mod=998244353;
typedef long long ll;
int qpow(int x,ll y) {
int z=1;
for(;y;y>>=1) {
if(y&1) z=1ll*z*x%Mod;
x=1ll*x*x%Mod;
}
return z;
}
int n,m;
int a[N];
int f[N][M];
int fac[N],inv[N];
int main() {
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
fac[0]=1;
for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%Mod;
inv[n]=qpow(fac[n],Mod-2);
for(int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;
f[0][0]=1;
for(int i=1;i<=n;i++) {
for(int j=i-1;j>=0;j--) {
for(int k=0;k<=j*200;k++) {
f[j+1][k+a[i]]=(f[j+1][k+a[i]]+f[j][k])%Mod;
}
}
}
int ans=0;
for(int i=1;i<=n;i++) {
for(int j=0;j<=i*200;j++) {
int val=m;
if(j<=i*m) val=1ll*j*qpow(i,Mod-2)%Mod;
ans=(ans+1ll*val*f[i][j]%Mod*inv[n]%Mod*fac[i]%Mod*fac[n-i]%Mod)%Mod;
}
}
printf("%d",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
3 3 2 3 4
output:
499122185
result:
ok 1 number(s): "499122185"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
5 1 10 20 30 40 50
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
1 9 37
output:
9
result:
ok 1 number(s): "9"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
5 5 24 41 29 6 40
output:
25
result:
ok 1 number(s): "25"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
10 34 91 86 1 14 98 13 85 64 91 20
output:
707882334
result:
ok 1 number(s): "707882334"
Test #6:
score: -100
Wrong Answer
time: 52ms
memory: 6984kb
input:
100 9 83 99 170 80 174 137 1 91 111 35 69 39 148 76 142 90 105 30 114 176 196 85 26 109 162 167 171 148 169 162 159 3 4 6 33 61 163 7 77 63 8 20 13 51 26 11 149 136 134 187 96 95 113 104 128 48 167 74 18 91 200 62 167 32 5 180 189 39 63 111 68 72 81 128 42 13 57 180 111 91 83 177 34 45 158 29 114 33...
output:
306152335
result:
wrong answer 1st numbers differ - expected: '82380556', found: '306152335'