QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#498450#8815. Space StationxinhaowenWA 245ms9868kbC++141.5kb2024-07-30 15:01:202024-07-30 15:01:21

Judging History

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

  • [2024-07-30 16:51:06]
  • hack成功,自动添加数据
  • (/hack/760)
  • [2024-07-30 15:01:21]
  • 评测
  • 测评结果:WA
  • 用时:245ms
  • 内存:9868kb
  • [2024-07-30 15:01:20]
  • 提交

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][20004],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]=inv[1]=fac[0]=1;
	for(int i=2;i<=n;++i)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=n;++i)fac[i]=fac[i-1]*i%mod,inv[i]=inv[i]*inv[i-1]%mod;
	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*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;
}

詳細信息

Test #1:

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

input:

3 3
2 3 4

output:

499122185

result:

ok 1 number(s): "499122185"

Test #2:

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

input:

5 1
10 20 30 40 50

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

1 9
37

output:

9

result:

ok 1 number(s): "9"

Test #4:

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

input:

5 5
24 41 29 6 40

output:

25

result:

ok 1 number(s): "25"

Test #5:

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

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: 210ms
memory: 8944kb

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: 245ms
memory: 9868kb

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:

595033029

result:

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