Submission #65681312
Source Code Expand
#include <iostream>
using namespace std;
#define ll long long
const ll Mmod = 998244353;
ll a, b, c, d, ans, w1, t1, w2;
ll Qpow(ll a, ll b) {
if (b == 0) return 1ll;
ll t = Qpow(a, b/2);
t = t * t % Mmod;
if (b % 2 == 1) t = t * a % Mmod;
return t;
}
ll C(int n, int m) { // C(n,m)
ll a = 1, b = 1;
for(int i = 1; i <= m; i++) b = b * i % Mmod;
for(int i = n-m+1; i <= n; i++) a = a * i % Mmod;
return a * Qpow(b, Mmod - 2) % Mmod;
}
int main ()
{
cin >> a >> b >> c >> d;
w1 = 1;
w2 = C(a+b+c, b);
ll x = a+b+c, y = a+c;
ans = (ans + w1 * w2 % Mmod) % Mmod;
for(ll c1 = 1; c1 <= c; c1++) {
w1 = w1 * (d+c1-1) % Mmod * Qpow(c1, Mmod-2) % Mmod;
w2 = w2 * y % Mmod * Qpow(x, Mmod-2) % Mmod;
x--, y--;
ans = (ans + w1 * w2 % Mmod) % Mmod;
}
cout << ans << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Fruit Lineup |
| User | gobywind |
| Language | C++ 20 (gcc 12.2) |
| Score | 475 |
| Code Size | 836 Byte |
| Status | AC |
| Exec Time | 427 ms |
| Memory | 3584 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 475 / 475 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_max_00.txt, 02_max_01.txt, 02_max_02.txt, 02_max_03.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3388 KiB |
| 00_sample_01.txt | AC | 1 ms | 3576 KiB |
| 00_sample_02.txt | AC | 196 ms | 3580 KiB |
| 01_random_00.txt | AC | 375 ms | 3584 KiB |
| 01_random_01.txt | AC | 88 ms | 3524 KiB |
| 01_random_02.txt | AC | 119 ms | 3500 KiB |
| 01_random_03.txt | AC | 50 ms | 3524 KiB |
| 01_random_04.txt | AC | 294 ms | 3576 KiB |
| 01_random_05.txt | AC | 256 ms | 3576 KiB |
| 01_random_06.txt | AC | 116 ms | 3520 KiB |
| 01_random_07.txt | AC | 42 ms | 3504 KiB |
| 01_random_08.txt | AC | 40 ms | 3380 KiB |
| 01_random_09.txt | AC | 53 ms | 3468 KiB |
| 02_max_00.txt | AC | 426 ms | 3516 KiB |
| 02_max_01.txt | AC | 426 ms | 3516 KiB |
| 02_max_02.txt | AC | 426 ms | 3512 KiB |
| 02_max_03.txt | AC | 427 ms | 3576 KiB |