結果

問題 No.797 Noelちゃんとピラミッド
ユーザー yuji9511yuji9511
提出日時 2019-03-15 21:30:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,605 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 147,792 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2023-09-14 13:01:46
合計ジャッジ時間 5,932 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
5,332 KB
testcase_01 AC 24 ms
5,404 KB
testcase_02 AC 24 ms
5,516 KB
testcase_03 AC 37 ms
6,188 KB
testcase_04 AC 38 ms
6,084 KB
testcase_05 AC 38 ms
6,196 KB
testcase_06 AC 37 ms
6,164 KB
testcase_07 AC 38 ms
6,104 KB
testcase_08 AC 37 ms
6,240 KB
testcase_09 AC 37 ms
6,092 KB
testcase_10 AC 37 ms
6,088 KB
testcase_11 AC 38 ms
6,212 KB
testcase_12 AC 38 ms
6,240 KB
testcase_13 AC 37 ms
6,268 KB
testcase_14 AC 37 ms
6,112 KB
testcase_15 AC 37 ms
6,120 KB
testcase_16 AC 37 ms
6,104 KB
testcase_17 AC 37 ms
6,104 KB
testcase_18 AC 37 ms
6,212 KB
testcase_19 AC 37 ms
6,240 KB
testcase_20 AC 37 ms
6,216 KB
testcase_21 AC 37 ms
6,264 KB
testcase_22 AC 38 ms
6,236 KB
testcase_23 AC 34 ms
6,000 KB
testcase_24 AC 27 ms
5,556 KB
testcase_25 AC 32 ms
5,868 KB
testcase_26 AC 32 ms
5,780 KB
testcase_27 AC 37 ms
6,100 KB
testcase_28 AC 35 ms
6,032 KB
testcase_29 AC 26 ms
5,436 KB
testcase_30 AC 27 ms
5,568 KB
testcase_31 AC 33 ms
5,896 KB
testcase_32 AC 28 ms
5,580 KB
testcase_33 AC 32 ms
5,796 KB
testcase_34 AC 30 ms
5,664 KB
testcase_35 AC 38 ms
6,272 KB
testcase_36 AC 26 ms
5,524 KB
testcase_37 AC 36 ms
6,112 KB
testcase_38 AC 36 ms
6,148 KB
testcase_39 AC 32 ms
5,764 KB
testcase_40 AC 26 ms
5,420 KB
testcase_41 AC 26 ms
5,688 KB
testcase_42 AC 32 ms
5,924 KB
testcase_43 AC 25 ms
5,464 KB
testcase_44 AC 24 ms
5,336 KB
testcase_45 AC 24 ms
5,344 KB
testcase_46 AC 24 ms
5,388 KB
testcase_47 AC 25 ms
5,460 KB
testcase_48 AC 24 ms
5,384 KB
testcase_49 AC 25 ms
5,604 KB
testcase_50 AC 24 ms
5,336 KB
testcase_51 AC 25 ms
5,440 KB
testcase_52 AC 24 ms
5,464 KB
testcase_53 AC 25 ms
5,468 KB
testcase_54 AC 24 ms
5,436 KB
testcase_55 AC 25 ms
5,312 KB
testcase_56 AC 25 ms
5,392 KB
testcase_57 AC 24 ms
5,384 KB
testcase_58 AC 25 ms
5,332 KB
testcase_59 AC 24 ms
5,380 KB
testcase_60 AC 25 ms
5,336 KB
testcase_61 AC 25 ms
5,312 KB
testcase_62 AC 25 ms
5,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18 + 7)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010];
    cin >> N;
    rep(i,0,N) cin >> A[i];
    Combination comb(100010);
    ll ans = 0;
    rep(i,0,N){
        ans += comb.nck(N-1, i) * A[i] % MOD;
        ans %= MOD;
    }
    print(ans);

    


 }
0