QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717779#9436. Some Sum of SubsetjimmyywangWA 11ms74352kbC++141.0kb2024-11-06 18:56:102024-11-06 18:56:14

Judging History

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

  • [2024-11-06 18:56:14]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:74352kb
  • [2024-11-06 18:56:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;i++)
ll read(){
    ll x=0,f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c)){x=x*10+c-'0';c=getchar();}
    return x*f;
}
#define d read()
const ll mod=998244353;
ll C[3030][3030];
ll dp[3030],s;
ll n,m;
ll a[3010];
ll res[3030];
int main(){
    C[0][0]=1;
    f(i,1,3000){
        C[i][0]=1;
        f(j,1,i){
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
        }
    }n=d,m=d;f(i,1,n)a[i]=d;
    sort(a+1,a+n+1,greater<ll>());
    dp[0]=1;f(i,1,n){
        ll t=0;f(j,m-a[i],m)t=(t+dp[j])%mod;
        // cout<<i<<" "<<t<<endl;
        f(j,0,n)res[j]=(res[j]+C[n-i][j]*t)%mod;
        dp[m]=dp[m]*2%mod;
        f(j,m-a[i],m-1)dp[m]=(dp[m]+dp[j])%mod;
        for(int j=m-1-a[i];j>=0;j--){
            dp[j+a[i]]=(dp[j+a[i]]+dp[j])%mod;
        }
        // f(j,0,m)cout<<dp[j]<<" ";cout<<endl;
    }f(i,0,n)cout<<res[i]<<endl;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 74352kb

input:

4 7
3 1 5 2

output:

6
4
1
0
0

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 7ms
memory: 74104kb

input:

1 5
7

output:

1
0

result:

ok 2 tokens

Test #3:

score: 0
Accepted
time: 8ms
memory: 73592kb

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: 11ms
memory: 73440kb

input:

1 1467
556

output:

0
0

result:

ok 2 tokens

Test #5:

score: -100
Wrong Answer
time: 5ms
memory: 73812kb

input:

1 1753
2514

output:

1755
0

result:

wrong answer 1st words differ - expected: '1', found: '1755'