結果

問題 No.797 Noelちゃんとピラミッド
ユーザー Mcpu3
提出日時 2019-03-15 22:46:12
言語 C++14
(gcc 8.2.0)
結果
WA   .
実行時間 -
コード長 863 Byte
コンパイル時間 461 ms
使用メモリ 8,920 KB
最終ジャッジ日時 2019-06-28 11:46:35

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt AC 2 ms
6,872 KB
002sample.txt AC 3 ms
6,872 KB
003sample.txt AC 2 ms
6,872 KB
LEARGE_case1.txt AC 70 ms
6,868 KB
LEARGE_case2.txt WA -
LEARGE_case3.txt WA -
LEARGE_case4.txt WA -
LEARGE_case5.txt WA -
LEARGE_case6.txt AC 69 ms
6,872 KB
LEARGE_case7.txt WA -
LEARGE_case8.txt AC 69 ms
6,872 KB
LEARGE_case9.txt WA -
LEARGE_case10.txt WA -
LEARGE_case11.txt WA -
LEARGE_case12.txt WA -
LEARGE_case13.txt WA -
LEARGE_case14.txt AC 70 ms
6,872 KB
LEARGE_case15.txt AC 70 ms
6,872 KB
LEARGE_case16.txt AC 70 ms
6,868 KB
LEARGE_case17.txt WA -
LEARGE_case18.txt AC 71 ms
6,872 KB
LEARGE_case19.txt AC 70 ms
6,872 KB
LEARGE_case20.txt AC 71 ms
6,872 KB
RANDOM_case1.txt AC 55 ms
6,872 KB
RANDOM_case2.txt WA -
RANDOM_case3.txt AC 44 ms
6,872 KB
RANDOM_case4.txt WA -
RANDOM_case5.txt AC 69 ms
6,868 KB
RANDOM_case6.txt AC 64 ms
8,912 KB
RANDOM_case7.txt AC 12 ms
6,868 KB
RANDOM_case8.txt AC 18 ms
6,868 KB
RANDOM_case9.txt WA -
RANDOM_case10.txt AC 23 ms
6,868 KB
RANDOM_case11.txt AC 45 ms
6,872 KB
RANDOM_case12.txt AC 31 ms
8,920 KB
RANDOM_case13.txt WA -
RANDOM_case14.txt AC 11 ms
6,872 KB
RANDOM_case15.txt AC 63 ms
6,868 KB
RANDOM_case16.txt WA -
RANDOM_case17.txt WA -
RANDOM_case18.txt AC 12 ms
6,868 KB
RANDOM_case19.txt WA -
RANDOM_case20.txt AC 41 ms
6,872 KB
SMALL_case1.txt WA -
SMALL_case2.txt AC 2 ms
6,872 KB
SMALL_case3.txt AC 3 ms
6,872 KB
SMALL_case4.txt AC 2 ms
6,868 KB
SMALL_case5.txt AC 3 ms
6,868 KB
SMALL_case6.txt WA -
SMALL_case7.txt WA -
SMALL_case8.txt WA -
SMALL_case9.txt WA -
SMALL_case10.txt AC 3 ms
6,872 KB
SMALL_case11.txt WA -
SMALL_case12.txt AC 2 ms
8,916 KB
SMALL_case13.txt WA -
SMALL_case14.txt AC 2 ms
6,872 KB
SMALL_case15.txt WA -
SMALL_case16.txt WA -
SMALL_case17.txt AC 3 ms
6,872 KB
SMALL_case18.txt WA -
SMALL_case19.txt AC 2 ms
6,868 KB
SMALL_case20.txt 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 * inv[mod % i] % mod;
			finv[i] = inv[i] * finv[i - 1] % mod;
		}
	}

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