結果

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

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt AC 3 ms
1,492 KB
002sample.txt AC 2 ms
1,492 KB
003sample.txt AC 3 ms
1,492 KB
LEARGE_case1.txt AC 72 ms
4,460 KB
LEARGE_case2.txt WA -
LEARGE_case3.txt WA -
LEARGE_case4.txt WA -
LEARGE_case5.txt WA -
LEARGE_case6.txt AC 71 ms
4,456 KB
LEARGE_case7.txt WA -
LEARGE_case8.txt AC 71 ms
4,456 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 72 ms
4,460 KB
LEARGE_case15.txt AC 71 ms
4,460 KB
LEARGE_case16.txt AC 72 ms
4,456 KB
LEARGE_case17.txt WA -
LEARGE_case18.txt AC 72 ms
4,456 KB
LEARGE_case19.txt AC 72 ms
4,456 KB
LEARGE_case20.txt AC 71 ms
4,456 KB
RANDOM_case1.txt AC 52 ms
3,668 KB
RANDOM_case2.txt WA -
RANDOM_case3.txt AC 45 ms
3,136 KB
RANDOM_case4.txt WA -
RANDOM_case5.txt AC 69 ms
4,456 KB
RANDOM_case6.txt AC 63 ms
4,196 KB
RANDOM_case7.txt AC 12 ms
1,860 KB
RANDOM_case8.txt AC 18 ms
2,084 KB
RANDOM_case9.txt WA -
RANDOM_case10.txt AC 24 ms
2,344 KB
RANDOM_case11.txt AC 44 ms
3,140 KB
RANDOM_case12.txt AC 32 ms
2,612 KB
RANDOM_case13.txt WA -
RANDOM_case14.txt AC 11 ms
1,792 KB
RANDOM_case15.txt AC 63 ms
4,192 KB
RANDOM_case16.txt WA -
RANDOM_case17.txt WA -
RANDOM_case18.txt AC 11 ms
1,784 KB
RANDOM_case19.txt WA -
RANDOM_case20.txt AC 41 ms
3,140 KB
SMALL_case1.txt WA -
SMALL_case2.txt AC 4 ms
1,496 KB
SMALL_case3.txt AC 4 ms
1,500 KB
SMALL_case4.txt AC 4 ms
1,496 KB
SMALL_case5.txt AC 3 ms
1,492 KB
SMALL_case6.txt WA -
SMALL_case7.txt WA -
SMALL_case8.txt WA -
SMALL_case9.txt WA -
SMALL_case10.txt AC 3 ms
1,500 KB
SMALL_case11.txt WA -
SMALL_case12.txt AC 3 ms
1,492 KB
SMALL_case13.txt WA -
SMALL_case14.txt AC 4 ms
1,500 KB
SMALL_case15.txt WA -
SMALL_case16.txt WA -
SMALL_case17.txt AC 4 ms
1,496 KB
SMALL_case18.txt WA -
SMALL_case19.txt AC 3 ms
1,496 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