提出 #75874051
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template<class T> inline bool chmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
const int MOD =
998244353;
// combinatorics:
const int MAXN = 3e6 + 5;
long long fact[MAXN], invFact[MAXN];
long long modpow(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1)
res = (res * a) % MOD;
a = (a * a) % MOD;
b >>= 1;
}
return res;
}
void initCombinatorics() {
fact[0] = 1;
for (int i = 1; i < MAXN; i++)
fact[i] = (fact[i - 1] * i) % MOD;
invFact[MAXN - 1] = modpow(fact[MAXN - 1], MOD - 2);
for (int i = MAXN - 2; i >= 0; i--)
invFact[i] = (invFact[i + 1] * (i + 1)) % MOD;
}
long long nCr(int n, int r) {
if (r < 0 || r > n)
return 0;
return fact[n] * invFact[r] % MOD * invFact[n - r] % MOD;
}
long long nPr(int n, int r) {
if (r < 0 || r > n)
return 0;
return fact[n] * invFact[n - r] % MOD;
}
void solve() {
int x1,x2,x3;cin>>x1>>x2>>x3;
// 1 can come only negihtbouring 1 and 2;
// same for 2 and 3 ,
// most flexible 2 ;
// 1 and 3 cant be neighbour
// gaps = 2 +1;
int gaps=x2+1;
ll ans=0;
for(int i=1;i<=min(gaps,x1);i++){
ll choose1=nCr(gaps,i);
ll put1=nCr(x1-1,i-1);
ll put3=nCr(gaps-i+x3-1,x3);
ll curr=choose1*put1%MOD;
curr=(curr*put3)%MOD;
ans=(ans+curr)%MOD;
}
cout<<ans<<'\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = 1;
//cin >> tt;
initCombinatorics();
while (tt--) {
solve();
}
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | E - Count 123 |
| ユーザ | lavi3 |
| 言語 | C++23 (GCC 15.2.0) |
| 得点 | 450 |
| コード長 | 2054 Byte |
| 結果 | AC |
| 実行時間 | 45 ms |
| メモリ | 50612 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 450 / 450 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00-sample-01.txt | AC | 37 ms | 50404 KiB |
| 00-sample-02.txt | AC | 37 ms | 50528 KiB |
| 00-sample-03.txt | AC | 45 ms | 50380 KiB |
| 01-01.txt | AC | 38 ms | 50612 KiB |
| 01-02.txt | AC | 37 ms | 50416 KiB |
| 01-03.txt | AC | 39 ms | 50484 KiB |
| 01-04.txt | AC | 38 ms | 50572 KiB |
| 01-05.txt | AC | 42 ms | 50612 KiB |
| 01-06.txt | AC | 40 ms | 50528 KiB |
| 01-07.txt | AC | 37 ms | 50520 KiB |
| 01-08.txt | AC | 44 ms | 50404 KiB |
| 01-09.txt | AC | 44 ms | 50372 KiB |
| 01-10.txt | AC | 44 ms | 50484 KiB |
| 01-11.txt | AC | 37 ms | 50372 KiB |
| 01-12.txt | AC | 37 ms | 50444 KiB |
| 01-13.txt | AC | 37 ms | 50556 KiB |
| 01-14.txt | AC | 37 ms | 50372 KiB |
| 01-15.txt | AC | 40 ms | 50444 KiB |
| 01-16.txt | AC | 37 ms | 50612 KiB |
| 01-17.txt | AC | 37 ms | 50484 KiB |
| 01-18.txt | AC | 37 ms | 50372 KiB |
| 01-19.txt | AC | 41 ms | 50572 KiB |
| 01-20.txt | AC | 41 ms | 50556 KiB |
| 01-21.txt | AC | 41 ms | 50572 KiB |
| 01-22.txt | AC | 38 ms | 50552 KiB |
| 01-23.txt | AC | 41 ms | 50580 KiB |
| 01-24.txt | AC | 40 ms | 50564 KiB |
| 01-25.txt | AC | 41 ms | 50404 KiB |
| 01-26.txt | AC | 40 ms | 50376 KiB |
| 01-27.txt | AC | 41 ms | 50552 KiB |
| 01-28.txt | AC | 38 ms | 50520 KiB |
| 01-29.txt | AC | 40 ms | 50376 KiB |
| 01-30.txt | AC | 40 ms | 50612 KiB |