結果

問題 No.797 Noelちゃんとピラミッド
ユーザー Mcpu3Mcpu3
提出日時 2019-03-15 22:52:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 913 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 72,808 KB
実行使用メモリ 6,456 KB
最終ジャッジ日時 2023-09-14 14:00:46
合計ジャッジ時間 4,446 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 47 ms
6,168 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 45 ms
6,280 KB
testcase_09 WA -
testcase_10 AC 46 ms
6,180 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 46 ms
6,180 KB
testcase_17 AC 46 ms
6,256 KB
testcase_18 AC 47 ms
6,124 KB
testcase_19 WA -
testcase_20 AC 46 ms
6,088 KB
testcase_21 AC 46 ms
6,416 KB
testcase_22 AC 46 ms
6,268 KB
testcase_23 AC 34 ms
5,272 KB
testcase_24 WA -
testcase_25 AC 29 ms
4,808 KB
testcase_26 WA -
testcase_27 AC 44 ms
6,188 KB
testcase_28 AC 40 ms
5,696 KB
testcase_29 AC 7 ms
4,380 KB
testcase_30 AC 11 ms
4,380 KB
testcase_31 WA -
testcase_32 AC 15 ms
4,376 KB
testcase_33 AC 27 ms
4,828 KB
testcase_34 AC 20 ms
4,588 KB
testcase_35 WA -
testcase_36 AC 6 ms
4,376 KB
testcase_37 AC 40 ms
5,688 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 6 ms
4,380 KB
testcase_41 WA -
testcase_42 AC 26 ms
4,764 KB
testcase_43 WA -
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,376 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 1 ms
4,380 KB
testcase_53 WA -
testcase_54 AC 1 ms
4,376 KB
testcase_55 WA -
testcase_56 AC 1 ms
4,376 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 1 ms
4,380 KB
testcase_60 WA -
testcase_61 AC 2 ms
4,380 KB
testcase_62 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;

//	vector
template<typename T>
struct combination {
	vector<T> fct, inv, finv;
	int mod;
	
	combination(int size, int newMod) {
		fct = vector<T>(size + 1, 1);
		inv = vector<T>(size + 1, 1);
		finv = vector<T>(size + 1, 1);
		mod = newMod;
		for (int i = 2; i <= size; ++i) {
			fct[i] = fct[i - 1] * i % mod;
			inv[i] = mod - mod / i * (long)inv[mod % i] % mod;
			finv[i] = inv[i] * finv[i - 1] % mod;
		}
	}

	T combi(int n, int r) {
		if (n < 0 || n < r || r < 0) return 0;
		return fct[n] * (finv[r] * finv[n - r] % mod) % mod;
	}
};

int main() {
	int N;
	cin >> N;
	vector<long> a(N);
	for (long& i : a) cin >> i;
	long sum = 0;
	combination<long> cmb(N - 1, MOD);
	for (int i = 0; i < N; ++i) sum = a[i] * cmb.combi(N - 1, i) % MOD + sum % MOD;
	cout << sum;
}
0