結果

問題 No.797 Noelちゃんとピラミッド
ユーザー pockynypockyny
提出日時 2019-03-15 21:59:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 52,536 KB
実行使用メモリ 8,304 KB
最終ジャッジ日時 2023-09-14 13:33:06
合計ジャッジ時間 4,833 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
8,084 KB
testcase_01 AC 13 ms
8,068 KB
testcase_02 AC 12 ms
8,292 KB
testcase_03 AC 56 ms
8,056 KB
testcase_04 AC 57 ms
8,004 KB
testcase_05 AC 56 ms
7,988 KB
testcase_06 AC 56 ms
8,212 KB
testcase_07 AC 57 ms
8,008 KB
testcase_08 AC 56 ms
7,972 KB
testcase_09 AC 57 ms
7,992 KB
testcase_10 AC 56 ms
8,008 KB
testcase_11 AC 56 ms
8,008 KB
testcase_12 AC 55 ms
8,172 KB
testcase_13 AC 55 ms
7,992 KB
testcase_14 AC 56 ms
7,972 KB
testcase_15 AC 56 ms
7,976 KB
testcase_16 AC 56 ms
8,284 KB
testcase_17 AC 56 ms
8,008 KB
testcase_18 AC 56 ms
8,080 KB
testcase_19 AC 56 ms
7,996 KB
testcase_20 AC 57 ms
7,992 KB
testcase_21 AC 56 ms
8,068 KB
testcase_22 AC 56 ms
8,104 KB
testcase_23 AC 44 ms
7,968 KB
testcase_24 AC 23 ms
8,288 KB
testcase_25 AC 39 ms
7,992 KB
testcase_26 AC 38 ms
8,176 KB
testcase_27 AC 56 ms
8,032 KB
testcase_28 AC 51 ms
8,004 KB
testcase_29 AC 18 ms
8,292 KB
testcase_30 AC 23 ms
7,992 KB
testcase_31 AC 43 ms
7,976 KB
testcase_32 AC 26 ms
8,056 KB
testcase_33 AC 38 ms
7,988 KB
testcase_34 AC 31 ms
7,992 KB
testcase_35 AC 56 ms
8,304 KB
testcase_36 AC 17 ms
8,284 KB
testcase_37 AC 51 ms
8,064 KB
testcase_38 AC 53 ms
8,008 KB
testcase_39 AC 38 ms
8,140 KB
testcase_40 AC 18 ms
7,992 KB
testcase_41 AC 20 ms
8,216 KB
testcase_42 AC 37 ms
8,000 KB
testcase_43 AC 13 ms
8,064 KB
testcase_44 AC 13 ms
8,176 KB
testcase_45 AC 13 ms
7,988 KB
testcase_46 AC 13 ms
8,060 KB
testcase_47 AC 13 ms
7,976 KB
testcase_48 AC 13 ms
7,996 KB
testcase_49 AC 13 ms
8,124 KB
testcase_50 AC 13 ms
8,008 KB
testcase_51 AC 13 ms
8,144 KB
testcase_52 AC 13 ms
8,216 KB
testcase_53 AC 13 ms
8,012 KB
testcase_54 AC 13 ms
7,972 KB
testcase_55 AC 13 ms
7,988 KB
testcase_56 AC 13 ms
7,996 KB
testcase_57 AC 13 ms
8,032 KB
testcase_58 AC 13 ms
8,008 KB
testcase_59 AC 13 ms
8,028 KB
testcase_60 AC 13 ms
8,140 KB
testcase_61 AC 13 ms
7,992 KB
testcase_62 AC 13 ms
7,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;
typedef long long ll;
ll mod = 1000000007,inv[200010],fact[200010],fi[200010];
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<200010;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<200010;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(int n,int k){
	if(n<0 || k<0 || n<k) return 0;
	return fact[n]%mod*fi[k]%mod*fi[n-k]%mod;
}

ll ans = 0;
int main(){
	int i,n;
	cin >> n;
	inverse();
	for(i=0;i<n;i++){
		ll a; cin >> a;
		(ans += comb(n-1,i)*a%mod) %= mod;
	}
	cout << ans << endl;
}
0