結果

問題 No.797 Noelちゃんとピラミッド
ユーザー moririn2528_cmoririn2528_c
提出日時 2019-03-15 21:49:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,051 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 71,308 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 13:25:32
合計ジャッジ時間 5,882 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 76 ms
4,380 KB
testcase_04 AC 75 ms
4,376 KB
testcase_05 AC 76 ms
4,376 KB
testcase_06 AC 75 ms
4,376 KB
testcase_07 AC 76 ms
4,380 KB
testcase_08 AC 76 ms
4,376 KB
testcase_09 AC 76 ms
4,380 KB
testcase_10 AC 76 ms
4,380 KB
testcase_11 AC 76 ms
4,376 KB
testcase_12 AC 76 ms
4,380 KB
testcase_13 AC 76 ms
4,376 KB
testcase_14 AC 78 ms
4,376 KB
testcase_15 AC 76 ms
4,376 KB
testcase_16 AC 76 ms
4,376 KB
testcase_17 AC 76 ms
4,380 KB
testcase_18 AC 76 ms
4,380 KB
testcase_19 AC 75 ms
4,380 KB
testcase_20 AC 75 ms
4,376 KB
testcase_21 AC 75 ms
4,376 KB
testcase_22 AC 75 ms
4,380 KB
testcase_23 AC 54 ms
4,376 KB
testcase_24 AC 18 ms
4,376 KB
testcase_25 AC 46 ms
4,380 KB
testcase_26 AC 44 ms
4,380 KB
testcase_27 AC 74 ms
4,380 KB
testcase_28 AC 66 ms
4,376 KB
testcase_29 AC 11 ms
4,380 KB
testcase_30 AC 17 ms
4,376 KB
testcase_31 AC 55 ms
4,380 KB
testcase_32 AC 23 ms
4,376 KB
testcase_33 AC 45 ms
4,380 KB
testcase_34 AC 31 ms
4,380 KB
testcase_35 AC 75 ms
4,380 KB
testcase_36 AC 9 ms
4,376 KB
testcase_37 AC 65 ms
4,380 KB
testcase_38 AC 69 ms
4,380 KB
testcase_39 AC 45 ms
4,380 KB
testcase_40 AC 9 ms
4,380 KB
testcase_41 AC 13 ms
4,376 KB
testcase_42 AC 43 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 1 ms
4,380 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 1 ms
4,380 KB
testcase_53 AC 2 ms
4,376 KB
testcase_54 AC 2 ms
4,376 KB
testcase_55 AC 2 ms
4,380 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,376 KB
testcase_59 AC 2 ms
4,380 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 2 ms
4,504 KB
testcase_62 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;

LL nCk[100005];
const LL MAX=1e9+7;

long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
	//p_a^p_n mod p_p
	long long int p_b=1,p_t=1;
	for(;p_b<=p_n;p_b<<=1);
	for(p_b>>=1;p_b>0;p_b>>=1){
		p_t*=p_t;
		if(p_t>=p_p)p_t%=p_p;
		if(p_n&p_b)p_t*=p_a;
		if(p_t>=p_p)p_t%=p_p;
	}
	return p_t;
}

void nCk_mod(int c_n,long long int c_mod=1e9+7){
	long long int c_a=1;
	nCk[0]=1,nCk[c_n]=1;
	for(int i=0;i<c_n/2;i++){
		c_a*=(c_n-i);
		if(c_a>=c_mod)c_a%=c_mod;
		c_a*=pow_mod(i+1,c_mod-2,c_mod);
		if(c_a>=c_mod)c_a%=c_mod;
		nCk[i+1]=c_a,nCk[c_n-i-1]=c_a;
	}
}

int main(){
	int n;
	LL a,s=0;
	cin>>n;
	nCk_mod(n-1);
	for(int i=0;i<n;i++){
		cin>>a;
		s+=a*nCk[i];
		if(s>=MAX)s%=MAX;
	}
	cout<<s<<endl;
	return 0;
}

0