-
Notifications
You must be signed in to change notification settings - Fork 3
/
D.cpp
41 lines (39 loc) · 751 Bytes
/
D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using ll = long long;
using namespace std;
const int maxn = 100010, mod = 998244353;
int n, t;
int a[maxn];
ll qpow(ll num, int po = mod - 2) {
ll ret = 1;
for (; po; po >>= 1) {
if (po & 1)
ret = ret * num % mod;
num = num * num % mod;
}
return ret;
}
int main() {
cin >> n >> t;
int sumt = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sumt += a[i];
}
int free = t - sumt + 1;
ll ans = 1;
sumt = 0;
for (int i = 1; i <= n; i++) {
ans *= sumt + free + (n - i + 1);
ans %= mod;
sumt += a[i];
}
ans = ans * free % mod;
ans = ans * qpow(free + n) % mod;
cout << ans << endl;
return 0;
}