QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488974#8815. Space StationFffooooWA 246ms9140kbC++141.5kb2024-07-24 16:50:452024-07-24 16:50:45

Judging History

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

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

answer

#include<cstdio>
#include<algorithm>
#define int long long
template<typename T>void read(T &x){
	x=0;bool f=0;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<1)+(x<<3)+(ch^48);
	if(f)x=-x;
}
void write(char x){putchar(x);}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x=-x;
	char stk[11];int cnt=0;
	do stk[++cnt]=x%10+48,x/=10;while(x);
	for(;cnt;)putchar(stk[cnt--]);
}
template<typename T,typename ...Args>void read(T &x,Args &...args){read(x);read(args...);}
template<typename T,typename ...Args>void write(T x,Args ...args){write(x);write(args...);}
template<typename T>T min(T x,T y){return x<y?x:y;}
template<typename T>T max(T x,T y){return x>y?x:y;}
const int mod=998244353;int n,m,a[10004],dp[104][10004],sum,fac[104],inv[104],ans;
int C(int n,int m){return fac[n]*inv[n-m]%mod*inv[m]%mod;}
int fast_pow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod)if(y&1)res=res*x%mod;
	return res;
}
signed main(){
	read(n,m);dp[0][0]=1;
	for(int i=1;i<=n;++i)read(a[i]),sum+=a[i];
	for(int i=1;i<=n;++i)for(int j=n;j;--j)for(int k=sum;k>=a[i];--k)(dp[j][k]+=dp[j-1][k-a[i]])%=mod;
	inv[0]=fac[0]=1;
	for(int i=1;i<=n;++i)fac[i]=fac[i-1]*i%mod,inv[i]=fast_pow(fac[i],mod-2);
	for(int i=1;i<=n;++i)for(int j=1;j<=sum;++j){
		int tmp=fast_pow(C(n,i),mod-2);
		if(j>i*m)(ans+=tmp*m%mod*dp[i][j]%mod)%=mod;
		else (ans+=tmp*fast_pow(i,mod-2)%mod*j%mod*dp[i][j]%mod)%=mod;
	}
	write(ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
2 3 4

output:

499122185

result:

ok 1 number(s): "499122185"

Test #2:

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

input:

5 1
10 20 30 40 50

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

1 9
37

output:

9

result:

ok 1 number(s): "9"

Test #4:

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

input:

5 5
24 41 29 6 40

output:

25

result:

ok 1 number(s): "25"

Test #5:

score: 0
Accepted
time: 1ms
memory: 1360kb

input:

10 34
91 86 1 14 98 13 85 64 91 20

output:

707882334

result:

ok 1 number(s): "707882334"

Test #6:

score: 0
Accepted
time: 203ms
memory: 8912kb

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:

82380556

result:

ok 1 number(s): "82380556"

Test #7:

score: -100
Wrong Answer
time: 246ms
memory: 9140kb

input:

100 33
24 157 144 142 151 8 93 54 189 74 12 129 77 95 59 13 159 48 67 116 174 194 9 166 170 84 136 68 39 181 133 190 37 115 42 95 134 148 91 59 130 1 68 48 14 126 193 50 192 196 44 85 37 96 66 39 180 129 22 2 17 101 45 159 171 68 113 142 197 156 63 96 185 108 72 69 144 33 115 142 139 11 57 76 126 19...

output:

349687113

result:

wrong answer 1st numbers differ - expected: '516465986', found: '349687113'