結果

問題 No.2792 Security Cameras on Young Diagram
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2024-07-03 09:24:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 2,610 ms
コンパイル使用メモリ 206,432 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-03 09:24:22
合計ジャッジ時間 3,159 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,816 KB
testcase_01 AC 5 ms
6,944 KB
testcase_02 AC 5 ms
6,940 KB
testcase_03 AC 4 ms
6,944 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 5 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 5 ms
6,944 KB
testcase_10 AC 5 ms
6,940 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 9 ms
6,944 KB
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 10 ms
6,940 KB
testcase_15 AC 6 ms
6,944 KB
testcase_16 AC 9 ms
6,940 KB
testcase_17 AC 11 ms
6,940 KB
testcase_18 AC 5 ms
6,944 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 AC 7 ms
6,944 KB
testcase_21 AC 4 ms
6,940 KB
testcase_22 AC 5 ms
6,944 KB
testcase_23 AC 13 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

const int MAX=2e5;

vector<mint> f, finv;

mint inv(mint x){
    mint ans = 1;
    int e = 998244351;

    while (e > 0){
        if ((e & 1LL)) ans *= x;
        e = e >> 1LL;
        x *= x;
    }

    return ans;
}

void init(){
    f.resize(MAX+1); finv.resize(MAX+1);
    f[0] = 1;
    for (int i=1; i<=MAX; i++) f[i] = f[i-1]*i;
    finv[MAX] = inv(f[MAX]);
    for (int i=MAX-1; i>=0; i--) finv[i] = finv[i+1] * (i+1);
}

mint C(int n, int k){
    if (n < k || k < 0) return 0;

    return f[n] * finv[k] * finv[n-k] ;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    init();

    int N, A;
    cin >> N;
    mint ans=0;
    for (int i=0; i<N; i++){
        cin >> A;
        ans += C(A+i, i+1);
    }
    cout << (ans+1).val() << endl;

    return 0;
}
0