結果

問題 No.797 Noelちゃんとピラミッド
ユーザー tempura_pptempura_pp
提出日時 2019-03-15 21:28:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 1,177 bytes
コンパイル時間 915 ms
コンパイル使用メモリ 98,364 KB
実行使用メモリ 6,496 KB
最終ジャッジ日時 2023-09-14 12:55:54
合計ジャッジ時間 4,768 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,412 KB
testcase_01 AC 5 ms
5,408 KB
testcase_02 AC 5 ms
5,432 KB
testcase_03 AC 43 ms
6,204 KB
testcase_04 AC 43 ms
6,280 KB
testcase_05 AC 43 ms
6,260 KB
testcase_06 AC 43 ms
6,208 KB
testcase_07 AC 44 ms
6,208 KB
testcase_08 AC 43 ms
6,348 KB
testcase_09 AC 43 ms
6,168 KB
testcase_10 AC 43 ms
6,312 KB
testcase_11 AC 44 ms
6,496 KB
testcase_12 AC 43 ms
6,224 KB
testcase_13 AC 44 ms
6,168 KB
testcase_14 AC 43 ms
6,264 KB
testcase_15 AC 44 ms
6,340 KB
testcase_16 AC 44 ms
6,224 KB
testcase_17 AC 44 ms
6,464 KB
testcase_18 AC 43 ms
6,256 KB
testcase_19 AC 43 ms
6,276 KB
testcase_20 AC 44 ms
6,312 KB
testcase_21 AC 44 ms
6,212 KB
testcase_22 AC 44 ms
6,204 KB
testcase_23 AC 33 ms
5,880 KB
testcase_24 AC 14 ms
5,692 KB
testcase_25 AC 28 ms
5,956 KB
testcase_26 AC 27 ms
5,964 KB
testcase_27 AC 43 ms
6,212 KB
testcase_28 AC 39 ms
6,288 KB
testcase_29 AC 10 ms
5,428 KB
testcase_30 AC 14 ms
5,692 KB
testcase_31 AC 33 ms
5,916 KB
testcase_32 AC 17 ms
5,684 KB
testcase_33 AC 28 ms
5,944 KB
testcase_34 AC 21 ms
5,784 KB
testcase_35 AC 44 ms
6,280 KB
testcase_36 AC 9 ms
5,520 KB
testcase_37 AC 39 ms
6,200 KB
testcase_38 AC 41 ms
6,296 KB
testcase_39 AC 27 ms
5,948 KB
testcase_40 AC 9 ms
5,356 KB
testcase_41 AC 11 ms
5,436 KB
testcase_42 AC 27 ms
5,936 KB
testcase_43 AC 5 ms
5,476 KB
testcase_44 AC 5 ms
5,436 KB
testcase_45 AC 5 ms
5,484 KB
testcase_46 AC 5 ms
5,416 KB
testcase_47 AC 5 ms
5,372 KB
testcase_48 AC 6 ms
5,428 KB
testcase_49 AC 5 ms
5,420 KB
testcase_50 AC 5 ms
5,352 KB
testcase_51 AC 5 ms
5,356 KB
testcase_52 AC 5 ms
5,432 KB
testcase_53 AC 5 ms
5,420 KB
testcase_54 AC 6 ms
5,428 KB
testcase_55 AC 5 ms
5,420 KB
testcase_56 AC 5 ms
5,676 KB
testcase_57 AC 6 ms
5,412 KB
testcase_58 AC 6 ms
5,496 KB
testcase_59 AC 5 ms
5,356 KB
testcase_60 AC 5 ms
5,356 KB
testcase_61 AC 5 ms
5,416 KB
testcase_62 AC 6 ms
5,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	rep(i,n){
		fact[i+1]=fact[i]*(i+1)%mod;
		if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
		invfact[i+1]=invfact[i]*inv[i+1]%mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
int main(){
	int n;
	cin>>n;
	mod_build();
	ll a[n];
	rep(i,n)cin>>a[i];
	ll ans=0;
	rep(i,n)ans+=comb(n-1,i)*a[i]%mod;
	cout<<ans%mod<<endl;
	return 0;
}
0