結果

問題 No.797 Noelちゃんとピラミッド
ユーザー TqkTqk
提出日時 2019-03-15 21:44:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 1,422 ms
コンパイル使用メモリ 165,476 KB
実行使用メモリ 5,168 KB
最終ジャッジ日時 2023-09-14 13:14:45
合計ジャッジ時間 5,059 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 41 ms
4,892 KB
testcase_04 AC 41 ms
5,028 KB
testcase_05 AC 40 ms
5,024 KB
testcase_06 AC 41 ms
4,904 KB
testcase_07 AC 41 ms
4,832 KB
testcase_08 AC 41 ms
4,836 KB
testcase_09 AC 41 ms
4,836 KB
testcase_10 AC 41 ms
4,832 KB
testcase_11 AC 41 ms
4,836 KB
testcase_12 AC 40 ms
5,092 KB
testcase_13 AC 41 ms
4,960 KB
testcase_14 AC 41 ms
5,092 KB
testcase_15 AC 40 ms
4,896 KB
testcase_16 AC 40 ms
4,868 KB
testcase_17 AC 41 ms
5,036 KB
testcase_18 AC 41 ms
5,168 KB
testcase_19 AC 41 ms
4,928 KB
testcase_20 AC 40 ms
5,164 KB
testcase_21 AC 41 ms
4,928 KB
testcase_22 AC 41 ms
4,996 KB
testcase_23 AC 29 ms
4,468 KB
testcase_24 AC 10 ms
4,376 KB
testcase_25 AC 25 ms
4,376 KB
testcase_26 AC 23 ms
4,380 KB
testcase_27 AC 40 ms
4,864 KB
testcase_28 AC 36 ms
4,748 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 10 ms
4,376 KB
testcase_31 AC 30 ms
4,396 KB
testcase_32 AC 13 ms
4,380 KB
testcase_33 AC 25 ms
4,376 KB
testcase_34 AC 17 ms
4,376 KB
testcase_35 AC 40 ms
4,860 KB
testcase_36 AC 6 ms
4,376 KB
testcase_37 AC 36 ms
4,740 KB
testcase_38 AC 38 ms
4,788 KB
testcase_39 AC 24 ms
4,380 KB
testcase_40 AC 5 ms
4,376 KB
testcase_41 AC 8 ms
4,380 KB
testcase_42 AC 23 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,376 KB
testcase_52 AC 2 ms
4,376 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 1 ms
4,376 KB
testcase_58 AC 1 ms
4,380 KB
testcase_59 AC 1 ms
4,380 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;typedef long long lint;typedef vector<lint> liv;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define linf 1152921504606846976
#define MAXN 100010

#define repi(i,a,b) for(int i=a;i<b;++i)
#define repr_(i,a) for(int i=a;i>=0;--i)
#define md 1000000007
lint powmod_h;
lint powmod(lint a,lint p){
	if(!p)return 1;
	if(p&1)return powmod(a,p-1)*a%md;
	else{
		powmod_h=powmod(a,p/2);
		return powmod_h*powmod_h%md;
	}
}
lint fa[100010],rfa[100010];//kaijou,gyakugen n==10^7kurai made
void setfa(lint n){
	fa[0]=1;
	repi(i,1,n)fa[i]=(fa[i-1]*i)%md;
	rfa[n-1]=powmod(fa[n-1],md-2);
	repr_(i,n-2)rfa[i]=(rfa[i+1]*(i+1))%md;
}
inline lint ncr(lint n,lint r){ return fa[n]*rfa[r]%md*rfa[n-r]%md; }

int main(){
	lint n;cin>>n;
	lint a,ans=0;
	setfa(n);
	rep(i,n){
		cin>>a;
		ans+=ncr(n-1,i)*a;
		ans%=md;
	}cout<<ans<<endl;
}
0