結果

問題 No.797 Noelちゃんとピラミッド
ユーザー asdf1asdf1
提出日時 2019-03-15 23:17:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,578 bytes
コンパイル時間 3,419 ms
コンパイル使用メモリ 146,212 KB
実行使用メモリ 10,380 KB
最終ジャッジ日時 2023-09-14 14:15:02
合計ジャッジ時間 4,723 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,404 KB
testcase_01 AC 3 ms
7,576 KB
testcase_02 AC 3 ms
7,476 KB
testcase_03 AC 17 ms
10,268 KB
testcase_04 AC 16 ms
10,240 KB
testcase_05 AC 17 ms
10,304 KB
testcase_06 AC 17 ms
10,320 KB
testcase_07 AC 17 ms
10,308 KB
testcase_08 AC 17 ms
10,156 KB
testcase_09 AC 17 ms
10,376 KB
testcase_10 AC 17 ms
10,256 KB
testcase_11 AC 17 ms
10,256 KB
testcase_12 AC 16 ms
10,224 KB
testcase_13 AC 17 ms
10,324 KB
testcase_14 AC 17 ms
10,136 KB
testcase_15 AC 16 ms
10,372 KB
testcase_16 AC 17 ms
10,140 KB
testcase_17 AC 16 ms
10,228 KB
testcase_18 AC 17 ms
10,296 KB
testcase_19 AC 17 ms
10,380 KB
testcase_20 AC 16 ms
10,304 KB
testcase_21 AC 16 ms
10,296 KB
testcase_22 AC 17 ms
10,248 KB
testcase_23 AC 12 ms
10,048 KB
testcase_24 AC 5 ms
7,596 KB
testcase_25 AC 12 ms
10,012 KB
testcase_26 AC 11 ms
9,916 KB
testcase_27 AC 17 ms
10,372 KB
testcase_28 AC 15 ms
10,052 KB
testcase_29 AC 4 ms
7,636 KB
testcase_30 AC 5 ms
7,588 KB
testcase_31 AC 13 ms
10,100 KB
testcase_32 AC 7 ms
7,540 KB
testcase_33 AC 11 ms
10,044 KB
testcase_34 AC 8 ms
7,652 KB
testcase_35 AC 17 ms
10,132 KB
testcase_36 AC 4 ms
7,400 KB
testcase_37 AC 15 ms
10,124 KB
testcase_38 AC 15 ms
10,196 KB
testcase_39 AC 11 ms
9,828 KB
testcase_40 AC 4 ms
7,528 KB
testcase_41 AC 4 ms
7,564 KB
testcase_42 AC 11 ms
9,876 KB
testcase_43 AC 3 ms
7,320 KB
testcase_44 AC 3 ms
7,308 KB
testcase_45 AC 3 ms
7,304 KB
testcase_46 AC 2 ms
7,480 KB
testcase_47 AC 2 ms
7,492 KB
testcase_48 AC 3 ms
7,428 KB
testcase_49 AC 3 ms
7,580 KB
testcase_50 AC 2 ms
7,380 KB
testcase_51 AC 3 ms
7,408 KB
testcase_52 AC 2 ms
7,316 KB
testcase_53 AC 2 ms
7,540 KB
testcase_54 AC 2 ms
7,400 KB
testcase_55 AC 2 ms
7,564 KB
testcase_56 AC 2 ms
7,560 KB
testcase_57 AC 2 ms
7,332 KB
testcase_58 AC 2 ms
7,384 KB
testcase_59 AC 2 ms
7,320 KB
testcase_60 AC 2 ms
7,320 KB
testcase_61 AC 3 ms
7,480 KB
testcase_62 AC 2 ms
7,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll rui[ohara];
ll deruta[ohara];
ll f[ohara],fr[ohara];

//-------------------------↓↓↓↓↓↓------------------------

ll mod_pow(ll xx,ll nn,ll mod){
    ll ret=1;
    while(nn>0){
        if(nn&1)ret=ret*xx%mod;
        xx=xx*xx%mod;
        nn>>=1;
    }
    return ret;
}

ll ncr(ll nn,ll r){
    if(nn<r)return 0;
    return f[nn]*fr[r]%MOD*fr[nn-r]%MOD;
}

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>n;
    rep(i,n)cin>>a[i];
    f[0]=1;
          rrep(i,1,n+3){
              f[i]=f[i-1]*i%MOD;
          }
          fr[n+2]=mod_pow(f[n+2],MOD-2,MOD);
          rrrep(i,n+1,0){
              fr[i]=fr[i+1]*(i+1)%MOD;
          }
          rep(i,n){
              (ans+=ncr(n-1,i)*a[i])%=MOD;
          }
          Cout(ans);
    return 0;
}
0