結果

問題 No.797 Noelちゃんとピラミッド
ユーザー Kutimoti_TKutimoti_T
提出日時 2019-03-15 23:25:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 1,059 ms
コンパイル使用メモリ 61,844 KB
実行使用メモリ 5,580 KB
最終ジャッジ日時 2023-09-14 14:20:05
合計ジャッジ時間 6,064 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 107 ms
5,356 KB
testcase_04 AC 107 ms
5,360 KB
testcase_05 AC 106 ms
5,312 KB
testcase_06 AC 107 ms
5,428 KB
testcase_07 AC 107 ms
5,580 KB
testcase_08 AC 107 ms
5,396 KB
testcase_09 AC 107 ms
5,400 KB
testcase_10 AC 107 ms
5,468 KB
testcase_11 AC 107 ms
5,356 KB
testcase_12 AC 107 ms
5,528 KB
testcase_13 AC 107 ms
5,356 KB
testcase_14 AC 107 ms
5,532 KB
testcase_15 AC 108 ms
5,356 KB
testcase_16 AC 106 ms
5,352 KB
testcase_17 AC 108 ms
5,304 KB
testcase_18 AC 108 ms
5,400 KB
testcase_19 AC 107 ms
5,400 KB
testcase_20 AC 107 ms
5,348 KB
testcase_21 AC 107 ms
5,416 KB
testcase_22 AC 107 ms
5,356 KB
testcase_23 AC 76 ms
4,612 KB
testcase_24 AC 25 ms
4,380 KB
testcase_25 AC 65 ms
4,376 KB
testcase_26 AC 62 ms
4,376 KB
testcase_27 AC 105 ms
5,400 KB
testcase_28 AC 94 ms
5,132 KB
testcase_29 AC 15 ms
4,376 KB
testcase_30 AC 24 ms
4,376 KB
testcase_31 AC 77 ms
4,636 KB
testcase_32 AC 33 ms
4,376 KB
testcase_33 AC 63 ms
4,380 KB
testcase_34 AC 44 ms
4,376 KB
testcase_35 AC 107 ms
5,428 KB
testcase_36 AC 12 ms
4,376 KB
testcase_37 AC 94 ms
5,100 KB
testcase_38 AC 98 ms
5,088 KB
testcase_39 AC 62 ms
4,376 KB
testcase_40 AC 12 ms
4,376 KB
testcase_41 AC 18 ms
4,380 KB
testcase_42 AC 60 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 1 ms
4,376 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 2 ms
4,376 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 2 ms
4,380 KB
testcase_62 AC 2 ms
4,376 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] % MOD) * 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) % MOD;

    cout << ans << endl;
}
0