結果

問題 No.797 Noelちゃんとピラミッド
ユーザー shinchanshinchan
提出日時 2019-03-16 13:26:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,093 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 144,788 KB
実行使用メモリ 6,672 KB
最終ジャッジ日時 2023-09-14 15:13:31
合計ジャッジ時間 4,771 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,952 KB
testcase_01 AC 6 ms
5,684 KB
testcase_02 AC 6 ms
5,748 KB
testcase_03 AC 19 ms
6,492 KB
testcase_04 AC 19 ms
6,432 KB
testcase_05 AC 19 ms
6,608 KB
testcase_06 AC 18 ms
6,480 KB
testcase_07 AC 18 ms
6,432 KB
testcase_08 AC 19 ms
6,524 KB
testcase_09 AC 19 ms
6,460 KB
testcase_10 AC 18 ms
6,444 KB
testcase_11 AC 19 ms
6,672 KB
testcase_12 AC 18 ms
6,500 KB
testcase_13 AC 19 ms
6,560 KB
testcase_14 AC 19 ms
6,528 KB
testcase_15 AC 18 ms
6,668 KB
testcase_16 AC 19 ms
6,472 KB
testcase_17 AC 19 ms
6,468 KB
testcase_18 AC 19 ms
6,664 KB
testcase_19 AC 19 ms
6,432 KB
testcase_20 AC 19 ms
6,528 KB
testcase_21 AC 18 ms
6,480 KB
testcase_22 AC 18 ms
6,524 KB
testcase_23 AC 15 ms
6,308 KB
testcase_24 AC 9 ms
5,976 KB
testcase_25 AC 13 ms
6,216 KB
testcase_26 AC 13 ms
6,336 KB
testcase_27 AC 18 ms
6,476 KB
testcase_28 AC 17 ms
6,384 KB
testcase_29 AC 8 ms
5,844 KB
testcase_30 AC 8 ms
5,904 KB
testcase_31 AC 15 ms
6,452 KB
testcase_32 AC 10 ms
6,124 KB
testcase_33 AC 14 ms
6,124 KB
testcase_34 AC 11 ms
6,068 KB
testcase_35 AC 19 ms
6,496 KB
testcase_36 AC 7 ms
5,744 KB
testcase_37 AC 17 ms
6,576 KB
testcase_38 AC 18 ms
6,600 KB
testcase_39 AC 14 ms
6,116 KB
testcase_40 AC 7 ms
5,732 KB
testcase_41 AC 8 ms
5,844 KB
testcase_42 AC 13 ms
6,132 KB
testcase_43 AC 6 ms
5,700 KB
testcase_44 AC 6 ms
5,884 KB
testcase_45 AC 6 ms
5,700 KB
testcase_46 AC 6 ms
5,660 KB
testcase_47 AC 6 ms
5,688 KB
testcase_48 AC 6 ms
5,696 KB
testcase_49 AC 6 ms
5,748 KB
testcase_50 AC 6 ms
5,692 KB
testcase_51 AC 6 ms
5,692 KB
testcase_52 AC 6 ms
5,704 KB
testcase_53 AC 6 ms
5,692 KB
testcase_54 AC 6 ms
5,744 KB
testcase_55 AC 6 ms
5,748 KB
testcase_56 AC 6 ms
5,680 KB
testcase_57 AC 6 ms
5,748 KB
testcase_58 AC 6 ms
5,748 KB
testcase_59 AC 6 ms
5,744 KB
testcase_60 AC 6 ms
5,712 KB
testcase_61 AC 6 ms
5,744 KB
testcase_62 AC 6 ms
5,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}
ll fac[100007],finv[100007],inv[100007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<100007;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 com(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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n==1){
        cout <<a[0]<<endl;
        return 0;
    }
    cominit();
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans+=a[i]*com(n-1,i);
        ans%=mod;
    }
    cout <<ans<<endl;
    return 0;
}





0