QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#488538#8815. Space StationmaojunWA 70ms7880kbC++23761b2024-07-24 10:32:112024-07-24 10:32:11

Judging History

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

  • [2024-07-30 16:51:06]
  • hack成功,自动添加数据
  • (/hack/760)
  • [2024-07-24 10:32:11]
  • 评测
  • 测评结果:WA
  • 用时:70ms
  • 内存:7880kb
  • [2024-07-24 10:32:11]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N=105,MOD=998244353;
int n,m,a[N],C[N][N];

int dp[N][N*N];
inline void add(int&x,int y){x+=y;x>=MOD&&(x-=MOD);}
inline ll inv(ll x){ll r=1;for(int y=MOD-2;y;y>>=1,x=x*x%MOD)if(y&1)r=r*x%MOD;return r;}
int main(){
	scanf("%d%d",&n,&m);int s=0;
	for(int i=1;i<=n;i++){scanf("%d",&a[i]);s+=a[i];}
	for(int i=0;i<=n;i++){C[i][0]=1;for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)for(int j=i;j;j--)
		for(int k=s;k>=a[i];k--)add(dp[j][k],dp[j-1][k-a[i]]);
	ll res=0;
	for(int i=0;i<n;i++)for(int j=0;j<=s;j++)if(dp[i][j])
		res=(res+(m*i>j?j*inv(i)%MOD:m)*dp[i][j]*inv(C[n][i]))%MOD;
	printf("%lld\n",res);
	return 0;
}

详细

Test #1:

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

input:

3 3
2 3 4

output:

499122185

result:

ok 1 number(s): "499122185"

Test #2:

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

input:

5 1
10 20 30 40 50

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

1 9
37

output:

9

result:

ok 1 number(s): "9"

Test #4:

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

input:

5 5
24 41 29 6 40

output:

25

result:

ok 1 number(s): "25"

Test #5:

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

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: 70ms
memory: 7880kb

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:

545727657

result:

wrong answer 1st numbers differ - expected: '82380556', found: '545727657'