結果

問題 No.797 Noelちゃんとピラミッド
ユーザー leaf_1415leaf_1415
提出日時 2019-03-15 21:29:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 909 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 52,604 KB
実行使用メモリ 7,516 KB
最終ジャッジ日時 2023-09-14 12:59:35
合計ジャッジ時間 9,008 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
6,468 KB
testcase_01 AC 80 ms
6,520 KB
testcase_02 AC 79 ms
6,512 KB
testcase_03 AC 118 ms
7,236 KB
testcase_04 AC 117 ms
7,220 KB
testcase_05 AC 116 ms
7,232 KB
testcase_06 AC 117 ms
7,516 KB
testcase_07 AC 117 ms
7,300 KB
testcase_08 AC 118 ms
7,296 KB
testcase_09 AC 117 ms
7,512 KB
testcase_10 AC 117 ms
7,228 KB
testcase_11 AC 117 ms
7,244 KB
testcase_12 AC 116 ms
7,516 KB
testcase_13 AC 117 ms
7,300 KB
testcase_14 AC 117 ms
7,244 KB
testcase_15 AC 118 ms
7,240 KB
testcase_16 AC 117 ms
7,244 KB
testcase_17 AC 118 ms
7,352 KB
testcase_18 AC 117 ms
7,232 KB
testcase_19 AC 117 ms
7,384 KB
testcase_20 AC 116 ms
7,392 KB
testcase_21 AC 118 ms
7,224 KB
testcase_22 AC 117 ms
7,336 KB
testcase_23 AC 107 ms
7,304 KB
testcase_24 AC 88 ms
6,676 KB
testcase_25 AC 102 ms
6,936 KB
testcase_26 AC 101 ms
6,904 KB
testcase_27 AC 116 ms
7,316 KB
testcase_28 AC 113 ms
7,140 KB
testcase_29 AC 84 ms
6,716 KB
testcase_30 AC 88 ms
6,668 KB
testcase_31 AC 107 ms
7,004 KB
testcase_32 AC 91 ms
6,972 KB
testcase_33 AC 102 ms
6,928 KB
testcase_34 AC 95 ms
6,844 KB
testcase_35 AC 118 ms
7,232 KB
testcase_36 AC 83 ms
6,524 KB
testcase_37 AC 113 ms
7,136 KB
testcase_38 AC 115 ms
7,184 KB
testcase_39 AC 102 ms
6,912 KB
testcase_40 AC 84 ms
6,568 KB
testcase_41 AC 86 ms
6,564 KB
testcase_42 AC 100 ms
6,932 KB
testcase_43 AC 80 ms
6,452 KB
testcase_44 AC 79 ms
6,452 KB
testcase_45 AC 80 ms
6,488 KB
testcase_46 AC 79 ms
6,512 KB
testcase_47 AC 79 ms
6,484 KB
testcase_48 AC 79 ms
6,464 KB
testcase_49 AC 79 ms
6,468 KB
testcase_50 AC 79 ms
6,444 KB
testcase_51 AC 79 ms
6,568 KB
testcase_52 AC 79 ms
6,728 KB
testcase_53 AC 79 ms
6,564 KB
testcase_54 AC 79 ms
6,488 KB
testcase_55 AC 79 ms
6,564 KB
testcase_56 AC 79 ms
6,484 KB
testcase_57 AC 79 ms
6,592 KB
testcase_58 AC 79 ms
6,444 KB
testcase_59 AC 80 ms
6,732 KB
testcase_60 AC 79 ms
6,464 KB
testcase_61 AC 79 ms
6,732 KB
testcase_62 AC 79 ms
6,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint n;
llint a[100005];

llint fact[200005], fact_inv[200005];

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 200005; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 200005; i++){
		fact_inv[i] = modpow(fact[i], mod-2);
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	make_fact();
	
	llint ans = 0;
	for(int i = 0; i < n; i++){
		ans += comb(n-1, i) * a[i] % mod;
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}
0