QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#454416 | #8815. Space Station | ucup-team1113 | WA | 46ms | 8196kb | C++17 | 1.8kb | 2024-06-24 21:22:36 | 2024-06-24 21:22:36 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long double db;
typedef long long ll;
const ll N = 2e2 + 10;
const ll M = 4e4 + 10;
const ll mod = 998244353;
const ll inf32 = 0x3f3f3f3f;
const ll inf64 = 5e18;
int fac[N];
int invFac[N];
int dp[N][M];
ll C(int a, int b) {
return (ll)fac[a] * invFac[a - b] % mod * invFac[b] % mod;
}
ll InvCn(int a, int b) {
return (ll)invFac[a] * fac[a - b] % mod * fac[b - 1] % mod;
}
ll qmi(ll a, ll b){
ll res = 1;
while (b){
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
ll inv(ll x) {return qmi(x, mod - 2);}
void init() {
fac[0] = 1;
for (int i = 1; i <= 100; i++) {
fac[i] = (ll)i * fac[i - 1] % mod;
}
invFac[100] = inv(fac[100]);
for (int i = 100; i > 0; i--) {
// cout << i << ' ' << invFac[i] << endl;
invFac[i - 1] = (ll)i * invFac[i] % mod;
}
}
void solve(){
int n, m;
cin >> n >> m;
vector<int> a(n + 1);
int mx = 0;
for (int i = 1; i <= n; ++i)
cin >> a[i], mx = max(a[i], mx);
dp[0][0] = 1;
for (int i = 1; i <= n; ++i)
for (int j = i; j >= 1; --j)
for (int l = 0; l <= (j - 1) * mx; ++l){
int r = l + a[i];
dp[j][r] = (dp[j][r] + dp[j - 1][l]) % mod;
}
ll sum = 0;
for (int c = 1; c <= n; ++c){
ll cur = 0;
for (int s = 1; s <= c * mx; ++s)
cur = (cur + ll(min(s, c * m) * dp[c][s])) % mod;
sum = (sum + cur * InvCn(n, c)) % mod;
}
cout << sum << endl;
}
signed main(){
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
init();
int t = 1;
//cin >> t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
3 3 2 3 4
output:
499122185
result:
ok 1 number(s): "499122185"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
5 1 10 20 30 40 50
output:
5
result:
ok 1 number(s): "5"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
1 9 37
output:
9
result:
ok 1 number(s): "9"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
5 5 24 41 29 6 40
output:
25
result:
ok 1 number(s): "25"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
10 34 91 86 1 14 98 13 85 64 91 20
output:
707882334
result:
ok 1 number(s): "707882334"
Test #6:
score: -100
Wrong Answer
time: 46ms
memory: 8196kb
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:
610866710
result:
wrong answer 1st numbers differ - expected: '82380556', found: '610866710'