結果

問題 No.797 Noelちゃんとピラミッド
ユーザー kyort0nkyort0n
提出日時 2019-03-15 21:30:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 1,243 bytes
コンパイル時間 1,161 ms
コンパイル使用メモリ 144,528 KB
実行使用メモリ 27,040 KB
最終ジャッジ日時 2023-09-14 13:03:25
合計ジャッジ時間 20,399 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 259 ms
26,916 KB
testcase_01 AC 261 ms
26,740 KB
testcase_02 AC 259 ms
26,840 KB
testcase_03 AC 272 ms
26,984 KB
testcase_04 AC 271 ms
26,796 KB
testcase_05 AC 270 ms
26,748 KB
testcase_06 AC 270 ms
26,732 KB
testcase_07 AC 271 ms
26,816 KB
testcase_08 AC 273 ms
26,840 KB
testcase_09 AC 271 ms
26,988 KB
testcase_10 AC 272 ms
26,804 KB
testcase_11 AC 272 ms
26,748 KB
testcase_12 AC 271 ms
26,744 KB
testcase_13 AC 271 ms
26,744 KB
testcase_14 AC 271 ms
27,016 KB
testcase_15 AC 271 ms
26,808 KB
testcase_16 AC 270 ms
26,800 KB
testcase_17 AC 270 ms
26,812 KB
testcase_18 AC 270 ms
26,752 KB
testcase_19 AC 270 ms
26,816 KB
testcase_20 AC 271 ms
26,824 KB
testcase_21 AC 272 ms
26,748 KB
testcase_22 AC 271 ms
26,920 KB
testcase_23 AC 267 ms
26,800 KB
testcase_24 AC 263 ms
26,900 KB
testcase_25 AC 268 ms
26,848 KB
testcase_26 AC 266 ms
26,796 KB
testcase_27 AC 271 ms
26,820 KB
testcase_28 AC 268 ms
26,876 KB
testcase_29 AC 260 ms
26,964 KB
testcase_30 AC 262 ms
26,744 KB
testcase_31 AC 267 ms
26,796 KB
testcase_32 AC 263 ms
26,848 KB
testcase_33 AC 266 ms
26,804 KB
testcase_34 AC 265 ms
26,808 KB
testcase_35 AC 271 ms
26,844 KB
testcase_36 AC 262 ms
27,000 KB
testcase_37 AC 269 ms
26,800 KB
testcase_38 AC 270 ms
26,984 KB
testcase_39 AC 266 ms
26,812 KB
testcase_40 AC 261 ms
26,732 KB
testcase_41 AC 261 ms
26,804 KB
testcase_42 AC 265 ms
26,748 KB
testcase_43 AC 258 ms
26,796 KB
testcase_44 AC 259 ms
26,752 KB
testcase_45 AC 260 ms
26,904 KB
testcase_46 AC 258 ms
26,816 KB
testcase_47 AC 259 ms
27,040 KB
testcase_48 AC 258 ms
26,816 KB
testcase_49 AC 259 ms
26,904 KB
testcase_50 AC 258 ms
26,816 KB
testcase_51 AC 258 ms
26,804 KB
testcase_52 AC 261 ms
26,804 KB
testcase_53 AC 259 ms
26,824 KB
testcase_54 AC 258 ms
26,800 KB
testcase_55 AC 259 ms
26,808 KB
testcase_56 AC 259 ms
26,728 KB
testcase_57 AC 258 ms
26,984 KB
testcase_58 AC 258 ms
26,796 KB
testcase_59 AC 258 ms
26,824 KB
testcase_60 AC 259 ms
27,020 KB
testcase_61 AC 259 ms
26,744 KB
testcase_62 AC 259 ms
26,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[1000000];
ll FactorialInv[1000000];
ll Factorial[1000000];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    inv[1] = 1;
    FactorialInv[1] = 1;
    Factorial[1] = 1;
    for(int i = 2; i < 1000000; i++){
        inv[i] = beki(i, mod - 2);
        Factorial[i] = Factorial[i - 1] * i % mod;
        FactorialInv[i] = FactorialInv[i - 1] * inv[i] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}
int main() {
    //cout.precision(10);
    init_combination();
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
        ll a;
        cin >> a;
        ans += combination(n - 1, i - 1) * a;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
0