結果

問題 No.797 Noelちゃんとピラミッド
ユーザー heno239heno239
提出日時 2019-03-15 21:28:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,764 bytes
コンパイル時間 999 ms
コンパイル使用メモリ 112,840 KB
実行使用メモリ 5,656 KB
最終ジャッジ日時 2023-09-14 12:58:28
合計ジャッジ時間 4,663 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 42 ms
5,412 KB
testcase_04 AC 42 ms
5,412 KB
testcase_05 AC 42 ms
5,404 KB
testcase_06 AC 42 ms
5,364 KB
testcase_07 AC 43 ms
5,388 KB
testcase_08 AC 42 ms
5,420 KB
testcase_09 AC 42 ms
5,432 KB
testcase_10 AC 43 ms
5,504 KB
testcase_11 AC 42 ms
5,652 KB
testcase_12 AC 43 ms
5,548 KB
testcase_13 AC 42 ms
5,424 KB
testcase_14 AC 42 ms
5,408 KB
testcase_15 AC 42 ms
5,656 KB
testcase_16 AC 42 ms
5,656 KB
testcase_17 AC 42 ms
5,436 KB
testcase_18 AC 42 ms
5,488 KB
testcase_19 AC 42 ms
5,344 KB
testcase_20 AC 42 ms
5,388 KB
testcase_21 AC 42 ms
5,380 KB
testcase_22 AC 42 ms
5,500 KB
testcase_23 AC 30 ms
4,760 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 26 ms
4,424 KB
testcase_26 AC 25 ms
4,496 KB
testcase_27 AC 41 ms
5,372 KB
testcase_28 AC 37 ms
5,156 KB
testcase_29 AC 7 ms
4,380 KB
testcase_30 AC 10 ms
4,376 KB
testcase_31 AC 30 ms
4,548 KB
testcase_32 AC 14 ms
4,376 KB
testcase_33 AC 25 ms
4,384 KB
testcase_34 AC 18 ms
4,376 KB
testcase_35 AC 42 ms
5,404 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 37 ms
5,112 KB
testcase_38 AC 39 ms
5,200 KB
testcase_39 AC 25 ms
4,376 KB
testcase_40 AC 6 ms
4,380 KB
testcase_41 AC 9 ms
4,380 KB
testcase_42 AC 24 ms
4,448 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 2 ms
4,376 KB
testcase_51 AC 2 ms
4,380 KB
testcase_52 AC 2 ms
4,376 KB
testcase_53 AC 2 ms
4,380 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 AC 2 ms
4,376 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,376 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 2 ms
4,376 KB
testcase_62 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
int n;
ll a[100000];

struct perm {
private:
	int sz;
	vector<ll> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		rep1(i, sz - 1) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		per(i, sz - 1) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	perm p(n);
	ll ans = 0;
	rep(i, n) {
		ans += p.comb(n - 1, i)*a[i] % mod;
		ans %= mod;
	}
	cout << ans << endl;
	//stop
	return 0;
}
0