QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488615#8815. Space Stationmsk_samaWA 40ms7912kbC++201.2kb2024-07-24 11:59:312024-07-24 11:59:32

Judging History

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

  • [2024-07-30 16:51:06]
  • hack成功,自动添加数据
  • (/hack/760)
  • [2024-07-24 11:59:32]
  • 评测
  • 测评结果:WA
  • 用时:40ms
  • 内存:7912kb
  • [2024-07-24 11:59:31]
  • 提交

answer

#include <bits/stdc++.h>
#define MISAKA main
#define ll long long
using namespace std;
inline int read(){
   char ch=getchar();int f=1,x=0;
   while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
   while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
   return x*f;
}
const double eps=1e-9;
const int N=101,inf=1e9,mod=998244353;
int n,m,sum=0,a[N],c[N][N],f[N][N*N];ll ans=0;
ll qpow(ll a,ll b){ll r=1;for(;b;b>>=1,a=a*a%mod)if(b&1)r=r*a%mod;return r;}
inline int MOD(int x){return x>mod?x-mod:x;}
signed MISAKA(){
    n=read(),m=read();
    for(int i=1;i<=n;i++) sum+=a[i]=read();
    for(int i=0;i<=n;i++){
        c[i][0]=1;
        for(int j=1;j<=i;j++) c[i][j]=MOD(c[i-1][j]+c[i-1][j-1]); 
    }
    f[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=i;j>=1;j--)
            for(int k=sum;k>=a[i];k--)
                f[j][k]=MOD(f[j][k]+f[j-1][k-a[i]]);
    for(int i=1;i<=n;i++){
        ll res=0;
        for(int j=1;j<=sum;j++)if(f[i][j])
            if(i*m<=j) res=MOD(res+1ll*f[i][j]*m%mod); 
            else res=MOD(res+1ll*f[i][j]*j%mod*qpow(i,mod-2)%mod); 
        ans=MOD(ans+res*qpow(c[n][i],mod-2)%mod);
    }
    printf("%lld",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
2 3 4

output:

499122185

result:

ok 1 number(s): "499122185"

Test #2:

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

input:

5 1
10 20 30 40 50

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

1 9
37

output:

9

result:

ok 1 number(s): "9"

Test #4:

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

input:

5 5
24 41 29 6 40

output:

25

result:

ok 1 number(s): "25"

Test #5:

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

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: 35ms
memory: 7912kb

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: 40ms
memory: 7852kb

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:

433060731

result:

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