結果

問題 No.797 Noelちゃんとピラミッド
ユーザー tokutoku
提出日時 2019-03-15 21:32:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,423 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 146,096 KB
実行使用メモリ 15,888 KB
最終ジャッジ日時 2023-09-14 13:05:20
合計ジャッジ時間 6,513 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
15,492 KB
testcase_01 AC 24 ms
15,264 KB
testcase_02 AC 23 ms
15,324 KB
testcase_03 AC 62 ms
15,656 KB
testcase_04 AC 63 ms
15,748 KB
testcase_05 AC 61 ms
15,700 KB
testcase_06 AC 62 ms
15,652 KB
testcase_07 AC 61 ms
15,564 KB
testcase_08 AC 61 ms
15,612 KB
testcase_09 AC 60 ms
15,844 KB
testcase_10 AC 61 ms
15,564 KB
testcase_11 AC 61 ms
15,612 KB
testcase_12 AC 61 ms
15,712 KB
testcase_13 AC 62 ms
15,752 KB
testcase_14 AC 62 ms
15,560 KB
testcase_15 AC 61 ms
15,608 KB
testcase_16 AC 61 ms
15,748 KB
testcase_17 AC 62 ms
15,600 KB
testcase_18 AC 62 ms
15,604 KB
testcase_19 AC 62 ms
15,844 KB
testcase_20 AC 61 ms
15,756 KB
testcase_21 AC 62 ms
15,612 KB
testcase_22 AC 61 ms
15,720 KB
testcase_23 AC 51 ms
15,528 KB
testcase_24 AC 31 ms
15,252 KB
testcase_25 AC 46 ms
15,624 KB
testcase_26 AC 45 ms
15,520 KB
testcase_27 AC 60 ms
15,692 KB
testcase_28 AC 57 ms
15,608 KB
testcase_29 AC 28 ms
15,420 KB
testcase_30 AC 30 ms
15,388 KB
testcase_31 AC 50 ms
15,384 KB
testcase_32 AC 35 ms
15,252 KB
testcase_33 AC 46 ms
15,300 KB
testcase_34 AC 40 ms
15,512 KB
testcase_35 AC 62 ms
15,612 KB
testcase_36 AC 26 ms
15,280 KB
testcase_37 AC 56 ms
15,668 KB
testcase_38 AC 58 ms
15,888 KB
testcase_39 AC 45 ms
15,348 KB
testcase_40 AC 27 ms
15,256 KB
testcase_41 AC 29 ms
15,612 KB
testcase_42 AC 43 ms
15,296 KB
testcase_43 AC 25 ms
15,348 KB
testcase_44 AC 24 ms
15,340 KB
testcase_45 AC 24 ms
15,256 KB
testcase_46 AC 24 ms
15,324 KB
testcase_47 AC 23 ms
15,468 KB
testcase_48 AC 24 ms
15,324 KB
testcase_49 AC 24 ms
15,388 KB
testcase_50 AC 24 ms
15,180 KB
testcase_51 AC 24 ms
15,324 KB
testcase_52 AC 25 ms
15,272 KB
testcase_53 AC 24 ms
15,184 KB
testcase_54 AC 23 ms
15,256 KB
testcase_55 AC 23 ms
15,264 KB
testcase_56 AC 24 ms
15,180 KB
testcase_57 AC 23 ms
15,292 KB
testcase_58 AC 22 ms
15,180 KB
testcase_59 AC 23 ms
15,324 KB
testcase_60 AC 24 ms
15,264 KB
testcase_61 AC 24 ms
15,180 KB
testcase_62 AC 22 ms
15,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main() {

	COMinit();


	int n;
	cin >> n;

	VLL v(n);
	REP(i, n)cin >> v[i];

	ll ans = 0;

	REP(i, n) {
		ans += COM(n-1, i)*v[i];
		ans %= mod;
	}

	cout << ans << endl;


}
0