結果

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

テストケース

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

ソースコード

diff #

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

using namespace std;
using namespace atcoder;

using mint = modint998244353;

const int MAX=2e5;

mint f[MAX+1], finv[MAX+1];

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

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

    return ans;
}

void init(){
    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){

    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