QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#498418 | #8815. Space Station | wy2025 | WA | 0ms | 11756kb | C++14 | 915b | 2024-07-30 14:18:49 | 2024-07-30 14:18:50 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=101,M=998244353;
int n,m,s,a[N],jc[N],inv[N],dp[N][N][N*200];
int ksm(int a,int b){int ans=1;while(b){if(b&1) ans=ans*a%M;b>>=1,a=a*a%M;}return ans;}
void init(){
jc[0]=jc[1]=1;
// inv[0]=inv[1]=1;
for(int i=2;i<N;i++)
jc[i]=jc[i-1]*i%M;
// inv[i]=ksm(jc[i]);
}
int iC(int n,int m){return ksm(n,M-2)*jc[m]%M*jc[n-m]%M;}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n>>m;
init();
for(int i=1;i<=n;i++) cin>>a[i],s+=a[i];
dp[0][0][0]=1;
for(int i=1;i<=n;i++)
for(int j=0;j<=i;j++)
for(int k=0;k<=s;k++){
dp[i][j][k]=dp[i-1][j][k];
if(j&&k>=a[i]) dp[i][j][k]=(dp[i][j][k]+dp[i-1][j-1][k-a[i]])%M;
}
int ans=0;
for(int i=1;i<=n;i++)
for(int j=0;j<=s;j++)
ans=(ans+dp[n][i][j]*iC(n,i)%M*min(m*i,j)%M*ksm(i,M-2)%M)%M;
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 11756kb
input:
3 3 2 3 4
output:
17
result:
wrong answer 1st numbers differ - expected: '499122185', found: '17'