結果

問題 No.797 Noelちゃんとピラミッド
ユーザー 沙耶花沙耶花
提出日時 2019-03-15 21:45:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,020 bytes
コンパイル時間 2,318 ms
コンパイル使用メモリ 170,124 KB
実行使用メモリ 4,756 KB
最終ジャッジ日時 2023-09-14 13:17:08
合計ジャッジ時間 6,575 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 42 ms
4,444 KB
testcase_04 AC 41 ms
4,452 KB
testcase_05 AC 42 ms
4,460 KB
testcase_06 AC 41 ms
4,596 KB
testcase_07 AC 41 ms
4,536 KB
testcase_08 AC 41 ms
4,604 KB
testcase_09 AC 41 ms
4,600 KB
testcase_10 AC 42 ms
4,524 KB
testcase_11 AC 41 ms
4,612 KB
testcase_12 AC 41 ms
4,528 KB
testcase_13 AC 41 ms
4,756 KB
testcase_14 AC 41 ms
4,524 KB
testcase_15 AC 42 ms
4,608 KB
testcase_16 AC 41 ms
4,536 KB
testcase_17 AC 41 ms
4,528 KB
testcase_18 AC 41 ms
4,448 KB
testcase_19 AC 41 ms
4,448 KB
testcase_20 AC 41 ms
4,528 KB
testcase_21 AC 41 ms
4,540 KB
testcase_22 AC 41 ms
4,540 KB
testcase_23 AC 31 ms
4,624 KB
testcase_24 AC 12 ms
4,376 KB
testcase_25 AC 26 ms
4,380 KB
testcase_26 AC 25 ms
4,424 KB
testcase_27 AC 40 ms
4,516 KB
testcase_28 AC 37 ms
4,544 KB
testcase_29 AC 8 ms
4,380 KB
testcase_30 AC 11 ms
4,376 KB
testcase_31 AC 31 ms
4,600 KB
testcase_32 AC 15 ms
4,380 KB
testcase_33 AC 26 ms
4,380 KB
testcase_34 AC 19 ms
4,380 KB
testcase_35 AC 42 ms
4,576 KB
testcase_36 AC 8 ms
4,376 KB
testcase_37 AC 36 ms
4,708 KB
testcase_38 AC 38 ms
4,420 KB
testcase_39 AC 26 ms
4,380 KB
testcase_40 AC 7 ms
4,376 KB
testcase_41 AC 10 ms
4,380 KB
testcase_42 AC 24 ms
4,380 KB
testcase_43 AC 4 ms
4,376 KB
testcase_44 AC 4 ms
4,380 KB
testcase_45 AC 4 ms
4,376 KB
testcase_46 AC 4 ms
4,380 KB
testcase_47 AC 4 ms
4,376 KB
testcase_48 AC 4 ms
4,376 KB
testcase_49 AC 3 ms
4,380 KB
testcase_50 AC 4 ms
4,376 KB
testcase_51 AC 4 ms
4,376 KB
testcase_52 AC 4 ms
4,380 KB
testcase_53 AC 4 ms
4,376 KB
testcase_54 AC 4 ms
4,380 KB
testcase_55 AC 3 ms
4,380 KB
testcase_56 AC 4 ms
4,376 KB
testcase_57 AC 4 ms
4,380 KB
testcase_58 AC 4 ms
4,380 KB
testcase_59 AC 4 ms
4,376 KB
testcase_60 AC 4 ms
4,376 KB
testcase_61 AC 3 ms
4,380 KB
testcase_62 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define modulo 1000000007
#define mod(x) (((long long)x)%modulo)


struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	void kaijou_set(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		int a = kaijou[n];int b = 1;int m = modulo-2;
		while(m!=0){
			if(m%2){
				b=mod(b*a);
			}
			a=mod(a*a);
			m/=2;
		}
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
};


int main(){
	int N;
	cin>>N;
	int a[N];
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	combi c;
	c.kaijou_set(100001);
	
	int ans = 0;
	for(int i=0;i<N;i++){
		int x = mod(c.combination(N-1,i)*a[i]);
		ans=mod(ans+x);
	}
	
	cout<<ans<<endl;
	
	return 0;
}
0