結果

問題 No.797 Noelちゃんとピラミッド
ユーザー polylogKpolylogK
提出日時 2018-01-25 01:10:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 164,192 KB
実行使用メモリ 5,240 KB
最終ジャッジ日時 2023-09-12 15:53:39
合計ジャッジ時間 6,247 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 67 ms
4,884 KB
testcase_04 AC 67 ms
5,240 KB
testcase_05 AC 67 ms
5,108 KB
testcase_06 AC 67 ms
5,152 KB
testcase_07 AC 67 ms
4,972 KB
testcase_08 AC 67 ms
4,892 KB
testcase_09 AC 67 ms
4,996 KB
testcase_10 AC 67 ms
4,924 KB
testcase_11 AC 67 ms
4,928 KB
testcase_12 AC 67 ms
4,912 KB
testcase_13 AC 67 ms
4,972 KB
testcase_14 AC 66 ms
5,192 KB
testcase_15 AC 67 ms
4,912 KB
testcase_16 AC 67 ms
4,888 KB
testcase_17 AC 67 ms
5,108 KB
testcase_18 AC 68 ms
5,224 KB
testcase_19 AC 67 ms
4,968 KB
testcase_20 AC 67 ms
4,968 KB
testcase_21 AC 66 ms
4,900 KB
testcase_22 AC 67 ms
4,908 KB
testcase_23 AC 48 ms
4,484 KB
testcase_24 AC 17 ms
4,380 KB
testcase_25 AC 42 ms
4,424 KB
testcase_26 AC 38 ms
4,376 KB
testcase_27 AC 65 ms
4,952 KB
testcase_28 AC 59 ms
4,784 KB
testcase_29 AC 10 ms
4,376 KB
testcase_30 AC 15 ms
4,376 KB
testcase_31 AC 48 ms
4,484 KB
testcase_32 AC 21 ms
4,380 KB
testcase_33 AC 40 ms
4,384 KB
testcase_34 AC 29 ms
4,380 KB
testcase_35 AC 67 ms
4,996 KB
testcase_36 AC 8 ms
4,380 KB
testcase_37 AC 58 ms
4,788 KB
testcase_38 AC 61 ms
4,796 KB
testcase_39 AC 39 ms
4,380 KB
testcase_40 AC 8 ms
4,384 KB
testcase_41 AC 12 ms
4,380 KB
testcase_42 AC 38 ms
4,384 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 2 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,384 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 1 ms
4,384 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,380 KB
testcase_60 AC 2 ms
4,380 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,a[100010],fact[100010];
ll ans=0;

ll inv(ll x){
	ll ret = 1, n = MOD-2;
	
	while(n){
		if(n&1) (ret*=x)%=MOD;
		(x*=x)%=MOD;
		n>>=1;
	}
	
	return ret;
}

ll comb(int a,int b){
	ll pos = fact[a];
	ll por = fact[b];
	ll pot = fact[a-b];
	
	return pos * inv(por) % MOD * inv(pot) %MOD;
}

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i]; fact[0]=1;
	REP(i,0,n) fact[i+1]=(fact[i]*(i+1))%MOD;
	
	REP(i,0,n) (ans+=a[i]*comb(n-1,i))%=MOD;
	cout << ans << endl;
	return 0;
}
0