QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717768#9436. Some Sum of SubsetjimmyywangWA 9ms74388kbC++141.0kb2024-11-06 18:55:002024-11-06 18:55:01

Judging History

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

  • [2024-11-06 18:55:01]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:74388kb
  • [2024-11-06 18:55:00]
  • 提交

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: 9ms
memory: 74268kb

input:

4 7
3 1 5 2

output:

6
4
1
0
0

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 9ms
memory: 74340kb

input:

1 5
7

output:

1
0

result:

ok 2 tokens

Test #3:

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

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: 73504kb

input:

1 1467
556

output:

0
0

result:

ok 2 tokens

Test #5:

score: -100
Wrong Answer
time: 4ms
memory: 74388kb

input:

1 1753
2514

output:

1755
0

result:

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