結果

問題 No.797 Noelちゃんとピラミッド
ユーザー Mcpu3Mcpu3
提出日時 2019-03-15 22:28:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 73,388 KB
実行使用メモリ 6,508 KB
最終ジャッジ日時 2023-09-14 13:46:31
合計ジャッジ時間 4,400 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 48 ms
6,084 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 47 ms
6,240 KB
testcase_09 WA -
testcase_10 AC 48 ms
6,244 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 48 ms
6,140 KB
testcase_17 AC 47 ms
6,240 KB
testcase_18 AC 47 ms
6,088 KB
testcase_19 WA -
testcase_20 AC 48 ms
6,268 KB
testcase_21 AC 48 ms
6,084 KB
testcase_22 AC 47 ms
6,140 KB
testcase_23 AC 35 ms
5,068 KB
testcase_24 WA -
testcase_25 AC 30 ms
5,052 KB
testcase_26 WA -
testcase_27 AC 46 ms
5,828 KB
testcase_28 AC 41 ms
5,600 KB
testcase_29 AC 7 ms
4,376 KB
testcase_30 AC 11 ms
4,376 KB
testcase_31 WA -
testcase_32 AC 15 ms
4,376 KB
testcase_33 AC 28 ms
4,804 KB
testcase_34 AC 20 ms
4,376 KB
testcase_35 WA -
testcase_36 AC 7 ms
4,380 KB
testcase_37 AC 42 ms
5,716 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 6 ms
4,376 KB
testcase_41 WA -
testcase_42 AC 27 ms
5,084 KB
testcase_43 WA -
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 1 ms
4,384 KB
testcase_53 WA -
testcase_54 AC 1 ms
4,376 KB
testcase_55 WA -
testcase_56 AC 2 ms
4,376 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 2 ms
4,376 KB
testcase_60 WA -
testcase_61 AC 2 ms
4,376 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;
	T mod;
	
	combination(int size, T 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 * inv[mod % i] % mod;
			finv[i] = inv[i] * finv[i - 1] % mod;
		}
	}

	T combi(T n, T r) {
		return finv[n - r] * finv[r] % mod * fct[n] % 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, 1000000007);
	for (int i = 0; i < N; ++i) sum = a[i] * cmb.combi(N - 1, i) % 1000000007 + sum % 1000000007;
	cout << sum;
}
0