結果

問題 No.797 Noelちゃんとピラミッド
ユーザー heabiheabi
提出日時 2020-11-22 18:27:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 2,122 bytes
コンパイル時間 1,435 ms
コンパイル使用メモリ 168,320 KB
実行使用メモリ 27,360 KB
最終ジャッジ日時 2023-09-30 23:01:17
合計ジャッジ時間 7,784 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
26,924 KB
testcase_01 AC 31 ms
26,768 KB
testcase_02 AC 33 ms
26,848 KB
testcase_03 AC 44 ms
27,172 KB
testcase_04 AC 43 ms
27,108 KB
testcase_05 AC 44 ms
27,100 KB
testcase_06 AC 45 ms
27,224 KB
testcase_07 AC 46 ms
27,084 KB
testcase_08 AC 44 ms
27,100 KB
testcase_09 AC 45 ms
27,172 KB
testcase_10 AC 43 ms
27,224 KB
testcase_11 AC 44 ms
27,092 KB
testcase_12 AC 43 ms
27,108 KB
testcase_13 AC 45 ms
27,100 KB
testcase_14 AC 46 ms
27,220 KB
testcase_15 AC 46 ms
27,224 KB
testcase_16 AC 43 ms
27,100 KB
testcase_17 AC 44 ms
27,360 KB
testcase_18 AC 42 ms
27,236 KB
testcase_19 AC 42 ms
27,228 KB
testcase_20 AC 43 ms
27,232 KB
testcase_21 AC 44 ms
27,104 KB
testcase_22 AC 44 ms
27,108 KB
testcase_23 AC 41 ms
26,824 KB
testcase_24 AC 34 ms
26,868 KB
testcase_25 AC 43 ms
26,976 KB
testcase_26 AC 39 ms
26,820 KB
testcase_27 AC 42 ms
27,108 KB
testcase_28 AC 41 ms
27,180 KB
testcase_29 AC 32 ms
26,952 KB
testcase_30 AC 33 ms
26,788 KB
testcase_31 AC 40 ms
27,236 KB
testcase_32 AC 35 ms
26,928 KB
testcase_33 AC 37 ms
26,840 KB
testcase_34 AC 40 ms
26,816 KB
testcase_35 AC 44 ms
27,232 KB
testcase_36 AC 31 ms
26,860 KB
testcase_37 AC 43 ms
27,236 KB
testcase_38 AC 44 ms
27,236 KB
testcase_39 AC 39 ms
26,972 KB
testcase_40 AC 33 ms
26,948 KB
testcase_41 AC 32 ms
26,956 KB
testcase_42 AC 36 ms
26,852 KB
testcase_43 AC 31 ms
26,888 KB
testcase_44 AC 29 ms
26,872 KB
testcase_45 AC 29 ms
26,820 KB
testcase_46 AC 30 ms
26,808 KB
testcase_47 AC 32 ms
26,816 KB
testcase_48 AC 31 ms
26,796 KB
testcase_49 AC 31 ms
26,868 KB
testcase_50 AC 29 ms
26,800 KB
testcase_51 AC 33 ms
26,852 KB
testcase_52 AC 30 ms
26,796 KB
testcase_53 AC 30 ms
26,828 KB
testcase_54 AC 33 ms
26,816 KB
testcase_55 AC 33 ms
26,792 KB
testcase_56 AC 30 ms
26,796 KB
testcase_57 AC 30 ms
26,928 KB
testcase_58 AC 31 ms
26,788 KB
testcase_59 AC 32 ms
26,804 KB
testcase_60 AC 33 ms
26,804 KB
testcase_61 AC 31 ms
26,868 KB
testcase_62 AC 30 ms
26,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
#define vvvvll vector<vector<vector<vector<ll>>>>
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>

constexpr ll INF = (1ll << 60);
// constexpr ll mod = 998244353;
constexpr ll mod = 1000000007;
// constexpr ll mod = 67280421310721;
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

void pt_vvll(vvll v) {
    ll vs = v.size(), vs0 = v[0].size();
    rep(i, vs) {
        rep(j, vs0) {
            cout << v[i][j];

            if (j != vs0 - 1)
                cout << " ";
            else
                cout << "\n";
        }
    }
}
void pt_vll(vll v) {
    ll vs = v.size();
    rep(i, vs) {
        cout << v[i];
        if (i == vs - 1)
            cout << "\n";
        else
            cout << " ";
    }
}
#define MAX 1000100
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算
ll combi(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    COMinit();
    ll N;
    cin >> N;
    vll a(N);
    rep(i, N) cin >> a[i];

    ll ans = 0;
    rep(i, N) {
        ans += (combi(N - 1, i) * a[i]) % mod;
        ans %= mod;
    }
    cout << ans << "\n";
    return 0;
}
0