結果

問題 No.797 Noelちゃんとピラミッド
ユーザー 41Toame41Toame
提出日時 2019-03-15 21:29:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 1,482 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 144,844 KB
実行使用メモリ 20,744 KB
最終ジャッジ日時 2023-09-14 12:59:44
合計ジャッジ時間 6,831 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
19,756 KB
testcase_01 AC 28 ms
19,720 KB
testcase_02 AC 28 ms
19,820 KB
testcase_03 AC 70 ms
20,564 KB
testcase_04 AC 70 ms
20,716 KB
testcase_05 AC 71 ms
20,520 KB
testcase_06 AC 70 ms
20,492 KB
testcase_07 AC 70 ms
20,480 KB
testcase_08 AC 70 ms
20,744 KB
testcase_09 AC 71 ms
20,640 KB
testcase_10 AC 70 ms
20,520 KB
testcase_11 AC 71 ms
20,536 KB
testcase_12 AC 70 ms
20,616 KB
testcase_13 AC 71 ms
20,516 KB
testcase_14 AC 70 ms
20,536 KB
testcase_15 AC 70 ms
20,620 KB
testcase_16 AC 70 ms
20,496 KB
testcase_17 AC 70 ms
20,516 KB
testcase_18 AC 70 ms
20,576 KB
testcase_19 AC 70 ms
20,520 KB
testcase_20 AC 70 ms
20,480 KB
testcase_21 AC 70 ms
20,548 KB
testcase_22 AC 71 ms
20,640 KB
testcase_23 AC 58 ms
20,324 KB
testcase_24 AC 38 ms
20,132 KB
testcase_25 AC 54 ms
20,196 KB
testcase_26 AC 53 ms
20,160 KB
testcase_27 AC 69 ms
20,568 KB
testcase_28 AC 66 ms
20,404 KB
testcase_29 AC 34 ms
19,856 KB
testcase_30 AC 37 ms
19,948 KB
testcase_31 AC 59 ms
20,500 KB
testcase_32 AC 41 ms
20,096 KB
testcase_33 AC 53 ms
20,248 KB
testcase_34 AC 46 ms
20,068 KB
testcase_35 AC 71 ms
20,496 KB
testcase_36 AC 33 ms
19,840 KB
testcase_37 AC 66 ms
20,500 KB
testcase_38 AC 67 ms
20,492 KB
testcase_39 AC 52 ms
20,156 KB
testcase_40 AC 33 ms
19,960 KB
testcase_41 AC 35 ms
19,880 KB
testcase_42 AC 52 ms
20,140 KB
testcase_43 AC 28 ms
19,720 KB
testcase_44 AC 28 ms
19,792 KB
testcase_45 AC 29 ms
19,848 KB
testcase_46 AC 28 ms
19,780 KB
testcase_47 AC 28 ms
19,788 KB
testcase_48 AC 29 ms
19,788 KB
testcase_49 AC 29 ms
19,708 KB
testcase_50 AC 29 ms
19,876 KB
testcase_51 AC 29 ms
19,724 KB
testcase_52 AC 28 ms
19,780 KB
testcase_53 AC 29 ms
19,872 KB
testcase_54 AC 29 ms
19,720 KB
testcase_55 AC 28 ms
19,792 KB
testcase_56 AC 28 ms
19,828 KB
testcase_57 AC 29 ms
19,816 KB
testcase_58 AC 28 ms
19,876 KB
testcase_59 AC 29 ms
20,016 KB
testcase_60 AC 28 ms
19,788 KB
testcase_61 AC 29 ms
19,748 KB
testcase_62 AC 28 ms
19,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 
int F[2100010];

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

void fact(void) {
	F[0] = 1;
	F[1] = 1;
	for (int i = 2; i <= 2100000; i++) {
		F[i] = Mul(i, F[i - 1]);
	}
}
int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int Div(int a, int b) {
	return Mul(a, power(b, mod - 2));
}
int P(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	return Div(F[n], F[n - r]);
}

int C(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	int ret;
	ret = Div(F[n], Mul(F[n - r], F[r]));
	return ret;
}
int H(int n, int r) {
	if (n == 0 && r == 0) return 1;
	return C(n + r - 1, r);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    fact();
    int a[100010];
    rep(i, N) cin >> a[i];
    int ans = 0;
    rep(i, N) ans = (ans +  Mul(a[i], C(N - 1, i))) % mod;
    cout << ans << endl;

    return 0;
}
0