結果

問題 No.797 Noelちゃんとピラミッド
ユーザー sifi_border
提出日時 2019-03-15 22:45:39
言語 C++14
(gcc 8.2.0)
結果
WA   .
実行時間 -
コード長 1,125 Byte
コンパイル時間 1,516 ms
使用メモリ 3,052 KB
最終ジャッジ日時 2019-04-08 18:28:00

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt WA -
002sample.txt WA -
003sample.txt WA -
LEARGE_case1.txt WA -
LEARGE_case2.txt WA -
LEARGE_case3.txt WA -
LEARGE_case4.txt WA -
LEARGE_case5.txt WA -
LEARGE_case6.txt WA -
LEARGE_case7.txt WA -
LEARGE_case8.txt WA -
LEARGE_case9.txt WA -
LEARGE_case10.txt WA -
LEARGE_case11.txt WA -
LEARGE_case12.txt WA -
LEARGE_case13.txt WA -
LEARGE_case14.txt WA -
LEARGE_case15.txt WA -
LEARGE_case16.txt WA -
LEARGE_case17.txt WA -
LEARGE_case18.txt WA -
LEARGE_case19.txt WA -
LEARGE_case20.txt WA -
RANDOM_case1.txt WA -
RANDOM_case2.txt WA -
RANDOM_case3.txt WA -
RANDOM_case4.txt WA -
RANDOM_case5.txt WA -
RANDOM_case6.txt WA -
RANDOM_case7.txt WA -
RANDOM_case8.txt WA -
RANDOM_case9.txt WA -
RANDOM_case10.txt WA -
RANDOM_case11.txt WA -
RANDOM_case12.txt WA -
RANDOM_case13.txt WA -
RANDOM_case14.txt WA -
RANDOM_case15.txt WA -
RANDOM_case16.txt WA -
RANDOM_case17.txt WA -
RANDOM_case18.txt WA -
RANDOM_case19.txt WA -
RANDOM_case20.txt WA -
SMALL_case1.txt WA -
SMALL_case2.txt WA -
SMALL_case3.txt WA -
SMALL_case4.txt WA -
SMALL_case5.txt WA -
SMALL_case6.txt WA -
SMALL_case7.txt WA -
SMALL_case8.txt WA -
SMALL_case9.txt WA -
SMALL_case10.txt WA -
SMALL_case11.txt WA -
SMALL_case12.txt WA -
SMALL_case13.txt WA -
SMALL_case14.txt WA -
SMALL_case15.txt WA -
SMALL_case16.txt WA -
SMALL_case17.txt WA -
SMALL_case18.txt WA -
SMALL_case19.txt WA -
SMALL_case20.txt WA -
テストケース一括ダウンロード

ソースコード

diff #
#include "bits/stdc++.h"

using namespace std;

const int MOD = 1e9 + 7;

#define MAX 100000
#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n - 1, i)

typedef long long ll;

//階乗とその逆元
ll fac[MAX + 1], facInv[MAX + 1];

ll power(ll e, ll x)
{ //e^x % MOD
	if (x == 0)
		return 1LL;
	if (x % 2 != 0)
		return ((power(e, x - 1) * e) % MOD);
	ll temp = power(e, x / 2);
	return (temp * temp) % MOD;
}

ll nck(ll n, ll k)
{
	if (!(n >= k && k >= 0))
		return 0;
	ll temp = (fac[n] * facInv[n - k]) % MOD;
	return ((temp * facInv[k]) % MOD);
}

void fact(void)
{
	//階乗とその逆元
	fac[0] = facInv[0] = 1; //0! = 1
	//(x!)^(-1) ≡ (x!)^(p-2) (mod p)
	Rep(1, MAX, i) fac[i] = (fac[i - 1] * i) % MOD;
	facInv[MAX] = power(fac[MAX], MOD - 2);
	Rep(1, MAX - 1, i) facInv[MAX - i] = (facInv[MAX - i + 1] * (MAX - i + 1)) % MOD;
}

void solve()
{
	int N;
	cin >> N;
	long ans = 0;
	fact();
	for (int i = 0; i < N; i++)
	{
		long a;
		cin >> a;
		ans += nck(N, i) * a;
		ans %= MOD;
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}
0