結果

問題 No.797 Noelちゃんとピラミッド
ユーザー ttttanttttan
提出日時 2019-03-16 18:30:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 841 bytes
コンパイル時間 1,149 ms
コンパイル使用メモリ 144,876 KB
実行使用メモリ 5,172 KB
最終ジャッジ日時 2023-09-14 15:24:35
合計ジャッジ時間 6,664 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 100 ms
5,104 KB
testcase_04 AC 100 ms
4,968 KB
testcase_05 AC 100 ms
5,172 KB
testcase_06 AC 99 ms
4,888 KB
testcase_07 AC 100 ms
4,880 KB
testcase_08 AC 100 ms
4,904 KB
testcase_09 AC 100 ms
4,900 KB
testcase_10 AC 100 ms
4,940 KB
testcase_11 AC 99 ms
4,960 KB
testcase_12 AC 100 ms
4,896 KB
testcase_13 AC 100 ms
4,908 KB
testcase_14 AC 99 ms
4,972 KB
testcase_15 AC 99 ms
4,956 KB
testcase_16 AC 99 ms
5,028 KB
testcase_17 AC 100 ms
5,028 KB
testcase_18 AC 99 ms
4,908 KB
testcase_19 AC 99 ms
5,100 KB
testcase_20 AC 100 ms
4,912 KB
testcase_21 AC 100 ms
4,916 KB
testcase_22 AC 100 ms
4,916 KB
testcase_23 AC 71 ms
4,524 KB
testcase_24 AC 23 ms
4,380 KB
testcase_25 AC 60 ms
4,380 KB
testcase_26 AC 57 ms
4,380 KB
testcase_27 AC 96 ms
4,876 KB
testcase_28 AC 88 ms
4,764 KB
testcase_29 AC 14 ms
4,376 KB
testcase_30 AC 22 ms
4,380 KB
testcase_31 AC 71 ms
4,456 KB
testcase_32 AC 31 ms
4,380 KB
testcase_33 AC 59 ms
4,380 KB
testcase_34 AC 41 ms
4,380 KB
testcase_35 AC 100 ms
5,024 KB
testcase_36 AC 12 ms
4,380 KB
testcase_37 AC 87 ms
4,688 KB
testcase_38 AC 91 ms
4,856 KB
testcase_39 AC 58 ms
4,380 KB
testcase_40 AC 12 ms
4,380 KB
testcase_41 AC 17 ms
4,380 KB
testcase_42 AC 55 ms
4,376 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,380 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,376 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 AC 2 ms
4,376 KB
testcase_62 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll gyaku(ll n){
    ll u=mod-2;
    ll ret=1;
    ll now=n;
    while(u>0){
        if(u%2==1){
            ret*=now;
            ret%=mod;
        }
        now=now*now;
        now%=mod;
        u/=2;
    }
    return ret;
}
ll nck(ll n,ll k){
    if(k>n)swap(n,k);
    if(2*k>n)k=n-k;
    ll ret=1;
    for(ll i=0;i<k;i++){
        ret*=n-i;
        ret%=mod;
        ret*=gyaku(i+1);
        ret%=mod;
    }
    return ret;
}
int main(){
    ll n;cin>>n;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    ll ans=0;
    ll f[n];
    f[0]=1;
    for(ll i=1;i<n;i++){
        f[i]=f[i-1]*(n-i);
        f[i]%=mod;
        f[i]*=gyaku(i);
        f[i]%=mod;
    }
    for(ll i=0;i<n;i++){
        ans+=f[i]*a[i];
        ans%=mod;
    }
    cout<<ans<<endl;
}
0