結果

問題 No.797 Noelちゃんとピラミッド
ユーザー ugis_progugis_prog
提出日時 2019-03-15 23:24:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 806 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 60,008 KB
実行使用メモリ 5,556 KB
最終ジャッジ日時 2023-09-14 14:18:29
合計ジャッジ時間 6,137 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 107 ms
5,276 KB
testcase_04 AC 107 ms
5,408 KB
testcase_05 AC 107 ms
5,324 KB
testcase_06 AC 107 ms
5,556 KB
testcase_07 AC 106 ms
5,360 KB
testcase_08 AC 105 ms
5,328 KB
testcase_09 AC 106 ms
5,416 KB
testcase_10 AC 107 ms
5,492 KB
testcase_11 AC 107 ms
5,352 KB
testcase_12 AC 107 ms
5,324 KB
testcase_13 AC 107 ms
5,400 KB
testcase_14 AC 107 ms
5,284 KB
testcase_15 AC 107 ms
5,316 KB
testcase_16 AC 106 ms
5,276 KB
testcase_17 AC 106 ms
5,320 KB
testcase_18 AC 107 ms
5,480 KB
testcase_19 AC 106 ms
5,424 KB
testcase_20 AC 106 ms
5,460 KB
testcase_21 AC 106 ms
5,412 KB
testcase_22 AC 106 ms
5,308 KB
testcase_23 AC 77 ms
4,524 KB
testcase_24 AC 25 ms
4,376 KB
testcase_25 AC 65 ms
4,376 KB
testcase_26 AC 61 ms
4,376 KB
testcase_27 AC 104 ms
5,348 KB
testcase_28 AC 93 ms
5,140 KB
testcase_29 AC 15 ms
4,380 KB
testcase_30 AC 23 ms
4,380 KB
testcase_31 AC 76 ms
4,608 KB
testcase_32 AC 33 ms
4,376 KB
testcase_33 AC 63 ms
4,376 KB
testcase_34 AC 45 ms
4,376 KB
testcase_35 AC 106 ms
5,424 KB
testcase_36 AC 13 ms
4,376 KB
testcase_37 AC 93 ms
5,140 KB
testcase_38 AC 96 ms
5,140 KB
testcase_39 AC 61 ms
4,380 KB
testcase_40 AC 13 ms
4,376 KB
testcase_41 AC 18 ms
4,376 KB
testcase_42 AC 59 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 1 ms
4,376 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 2 ms
4,376 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    vector<long long> factorial(N,1LL),nCr(N);
    const long long MOD = 1e9+7;
    for(int i=1;i<N;i++) factorial[i] = (factorial[i-1]*i) % MOD;
    for(int i=0;i<N;i++) {
        nCr[i] = (((factorial[N-1] * modinv(factorial[N-1-i],MOD)) % MOD) * modinv(factorial[i],MOD)) % MOD;
    } 

    long long ans = 0;
    for(int i=0;i<N;i++) ans=(ans+(nCr[i]*A[i])%MOD)%MOD;

    cout << ans << endl;
}
0