結果

問題 No.797 Noelちゃんとピラミッド
ユーザー polylogKpolylogK
提出日時 2019-03-15 22:57:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 70,668 KB
実行使用メモリ 5,604 KB
最終ジャッジ日時 2023-09-14 14:04:50
合計ジャッジ時間 6,346 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 101 ms
5,332 KB
testcase_04 AC 104 ms
5,328 KB
testcase_05 AC 98 ms
5,328 KB
testcase_06 AC 100 ms
5,352 KB
testcase_07 AC 100 ms
5,296 KB
testcase_08 AC 100 ms
5,300 KB
testcase_09 AC 101 ms
5,352 KB
testcase_10 AC 101 ms
5,532 KB
testcase_11 AC 100 ms
5,384 KB
testcase_12 AC 103 ms
5,604 KB
testcase_13 AC 102 ms
5,380 KB
testcase_14 AC 103 ms
5,372 KB
testcase_15 AC 105 ms
5,432 KB
testcase_16 AC 105 ms
5,336 KB
testcase_17 AC 106 ms
5,296 KB
testcase_18 AC 105 ms
5,468 KB
testcase_19 AC 105 ms
5,300 KB
testcase_20 AC 103 ms
5,392 KB
testcase_21 AC 105 ms
5,380 KB
testcase_22 AC 104 ms
5,332 KB
testcase_23 AC 73 ms
4,640 KB
testcase_24 AC 24 ms
4,380 KB
testcase_25 AC 63 ms
4,376 KB
testcase_26 AC 60 ms
4,572 KB
testcase_27 AC 102 ms
5,328 KB
testcase_28 AC 90 ms
5,076 KB
testcase_29 AC 14 ms
4,380 KB
testcase_30 AC 22 ms
4,376 KB
testcase_31 AC 70 ms
4,600 KB
testcase_32 AC 31 ms
4,380 KB
testcase_33 AC 60 ms
4,416 KB
testcase_34 AC 44 ms
4,380 KB
testcase_35 AC 100 ms
5,472 KB
testcase_36 AC 12 ms
4,380 KB
testcase_37 AC 90 ms
5,108 KB
testcase_38 AC 95 ms
5,076 KB
testcase_39 AC 61 ms
4,376 KB
testcase_40 AC 12 ms
4,380 KB
testcase_41 AC 18 ms
4,376 KB
testcase_42 AC 59 ms
4,412 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,384 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,384 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 2 ms
4,380 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 AC 2 ms
4,380 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,380 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 2 ms
4,380 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 1 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 += (nCr[i]*A[i] % MOD);

    cout << ans % MOD << endl;
}
0