結果

問題 No.797 Noelちゃんとピラミッド
ユーザー potoooooooopotoooooooo
提出日時 2019-03-19 14:53:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,089 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 164,880 KB
実行使用メモリ 8,364 KB
最終ジャッジ日時 2023-10-11 21:05:46
合計ジャッジ時間 7,302 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
8,168 KB
testcase_01 AC 7 ms
8,036 KB
testcase_02 AC 7 ms
8,032 KB
testcase_03 AC 44 ms
8,028 KB
testcase_04 AC 44 ms
8,084 KB
testcase_05 AC 44 ms
8,028 KB
testcase_06 AC 45 ms
8,224 KB
testcase_07 AC 44 ms
8,172 KB
testcase_08 AC 44 ms
8,172 KB
testcase_09 AC 44 ms
8,044 KB
testcase_10 AC 44 ms
8,120 KB
testcase_11 AC 44 ms
8,192 KB
testcase_12 AC 44 ms
8,084 KB
testcase_13 AC 44 ms
8,032 KB
testcase_14 AC 44 ms
8,108 KB
testcase_15 AC 44 ms
8,324 KB
testcase_16 AC 44 ms
8,040 KB
testcase_17 AC 44 ms
8,028 KB
testcase_18 AC 44 ms
8,112 KB
testcase_19 AC 45 ms
8,028 KB
testcase_20 AC 44 ms
8,036 KB
testcase_21 AC 44 ms
8,032 KB
testcase_22 AC 45 ms
8,232 KB
testcase_23 AC 34 ms
8,168 KB
testcase_24 AC 15 ms
8,088 KB
testcase_25 AC 29 ms
8,036 KB
testcase_26 AC 27 ms
8,088 KB
testcase_27 AC 43 ms
8,032 KB
testcase_28 AC 39 ms
8,104 KB
testcase_29 AC 11 ms
8,040 KB
testcase_30 AC 14 ms
8,100 KB
testcase_31 AC 33 ms
8,028 KB
testcase_32 AC 17 ms
8,032 KB
testcase_33 AC 29 ms
8,032 KB
testcase_34 AC 22 ms
8,092 KB
testcase_35 AC 43 ms
8,236 KB
testcase_36 AC 11 ms
8,032 KB
testcase_37 AC 39 ms
8,024 KB
testcase_38 AC 41 ms
8,104 KB
testcase_39 AC 28 ms
8,316 KB
testcase_40 AC 10 ms
8,116 KB
testcase_41 AC 13 ms
8,068 KB
testcase_42 AC 27 ms
8,036 KB
testcase_43 AC 7 ms
8,364 KB
testcase_44 AC 7 ms
8,092 KB
testcase_45 AC 6 ms
8,092 KB
testcase_46 AC 6 ms
8,112 KB
testcase_47 AC 7 ms
8,352 KB
testcase_48 AC 7 ms
8,104 KB
testcase_49 AC 6 ms
8,096 KB
testcase_50 AC 7 ms
8,032 KB
testcase_51 AC 6 ms
8,028 KB
testcase_52 AC 6 ms
8,064 KB
testcase_53 AC 6 ms
8,160 KB
testcase_54 AC 6 ms
8,088 KB
testcase_55 AC 7 ms
8,028 KB
testcase_56 AC 6 ms
8,036 KB
testcase_57 AC 7 ms
8,172 KB
testcase_58 AC 6 ms
8,028 KB
testcase_59 AC 6 ms
8,032 KB
testcase_60 AC 6 ms
8,104 KB
testcase_61 AC 6 ms
8,312 KB
testcase_62 AC 7 ms
8,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

int main() {
    GetInv(); GetFactorial();
    int n; cin >> n;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long c; cin >> c;
        ans = (ans + combination(n-1, i) * c % mod) % mod;
    }
    cout << ans << endl;
    return 0;
}
0