QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#784757#9436. Some Sum of SubsetUESTC_xxx#WA 1ms8084kbC++201.0kb2024-11-26 15:53:222024-11-26 15:53:56

Judging History

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

  • [2024-11-26 15:53:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8084kb
  • [2024-11-26 15:53:22]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#include<map>
#include<vector>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
const int mod=998244353;
int n,m,a[50005];
ll f[5005][5005],C[5005][5005],ans[5005],sum[5005];
int main(){
	scanf("%d%d",&n,&m);
	ll tot=1;
	for(int i=1;i<=n;++i) tot=tot*2LL%mod;
	C[0][0]=1;
	for(int i=1;i<=n;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	f[0][0]=1;
	sum[0]=1;
	for(int i=1;i<=n;++i){
		ll s=0;
		for(int j=0;j<m;++j){
			f[i][j]=f[i-1][j];
			if(j-a[i]>=0) f[i][j]+=f[i-1][j-a[i]];
			f[i][j]%=mod;
			sum[i]+=f[i][j];
			sum[i]%=mod;
		}
		s=sum[i]-sum[i-1];
		s=(s%mod+mod)%mod;
		for(int j=0;j<=n;++j){
			ans[j]=(ans[j]+s*C[n-i][j])%mod;
		}
	}
	tot--;
	for(int i=0;i<=n;++i){
		ans[i]=(tot-ans[i]+mod)%mod;
		tot-=C[n][i+1];
		printf("%lld\n",ans[i]);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 8064kb

input:

4 7
3 1 5 2

output:

6
4
1
0
0

result:

ok 5 tokens

Test #2:

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

input:

1 5
7

output:

1
0

result:

ok 2 tokens

Test #3:

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

input:

9 18
1 9 5 6 2 7 1 4 8

output:

346
309
230
126
46
10
1
0
0
0

result:

ok 10 tokens

Test #4:

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

input:

1 1467
556

output:

0
0

result:

ok 2 tokens

Test #5:

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

input:

1 1753
2514

output:

1
0

result:

ok 2 tokens

Test #6:

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

input:

1 1182
1182

output:

1
0

result:

ok 2 tokens

Test #7:

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

input:

2 1741
955 835

output:

1
0
0

result:

ok 3 tokens

Test #8:

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

input:

2 1481
2004 1570

output:

3
1
0

result:

ok 3 tokens

Test #9:

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

input:

2 1336
1336 1336

output:

3
1
0

result:

ok 3 tokens

Test #10:

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

input:

12 400
2163 2729 1322 2787 2404 1068 1502 746 898 2057 1771 502

output:

4095
4083
4017
3797
3302
2510
1586
794
299
79
13
1
0

result:

ok 13 tokens

Test #11:

score: -100
Wrong Answer
time: 1ms
memory: 8084kb

input:

42 1609
532 722 2650 2889 2260 659 1831 401 2779 1262 2185 1479 515 552 1627 637 1080 580 1589 2154 2650 219 2924 1712 311 2609 1062 968 1357 1310 1942 2419 2465 300 2546 2537 2967 1197 2271 1551 999 2531

output:

780135870
780135476
780133126
780115746
779984839
779086101
773744618
746617208
628409426
182368401
707355349
419830171
342550392
-219894413
-173023558
-19164296
-820275021
-929873143
-250243103
-810326803
-506092219
-710260371
-406025995
-966111004
-286486739
-396103880
-199018531
-45255200
-996777...

result:

wrong answer 14th words differ - expected: '778349940', found: '-219894413'