結果

問題 No.797 Noelちゃんとピラミッド
ユーザー hirokazu1020hirokazu1020
提出日時 2019-03-16 04:47:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,483 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 94,044 KB
実行使用メモリ 27,052 KB
最終ジャッジ日時 2023-09-14 15:04:51
合計ジャッジ時間 5,216 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
26,784 KB
testcase_01 AC 22 ms
26,832 KB
testcase_02 AC 22 ms
27,000 KB
testcase_03 AC 34 ms
27,004 KB
testcase_04 AC 35 ms
26,824 KB
testcase_05 AC 34 ms
26,820 KB
testcase_06 AC 35 ms
26,840 KB
testcase_07 AC 35 ms
26,772 KB
testcase_08 AC 35 ms
26,824 KB
testcase_09 AC 34 ms
26,752 KB
testcase_10 AC 34 ms
26,768 KB
testcase_11 AC 34 ms
26,784 KB
testcase_12 AC 34 ms
26,780 KB
testcase_13 AC 35 ms
26,824 KB
testcase_14 AC 34 ms
26,928 KB
testcase_15 AC 35 ms
26,828 KB
testcase_16 AC 35 ms
26,768 KB
testcase_17 AC 35 ms
26,828 KB
testcase_18 AC 35 ms
26,828 KB
testcase_19 AC 35 ms
26,932 KB
testcase_20 AC 34 ms
26,824 KB
testcase_21 AC 35 ms
26,832 KB
testcase_22 AC 35 ms
26,840 KB
testcase_23 AC 32 ms
26,780 KB
testcase_24 AC 25 ms
26,832 KB
testcase_25 AC 30 ms
26,932 KB
testcase_26 AC 30 ms
26,748 KB
testcase_27 AC 35 ms
26,768 KB
testcase_28 AC 33 ms
26,768 KB
testcase_29 AC 24 ms
26,864 KB
testcase_30 AC 25 ms
26,824 KB
testcase_31 AC 31 ms
26,844 KB
testcase_32 AC 26 ms
26,848 KB
testcase_33 AC 30 ms
27,008 KB
testcase_34 AC 28 ms
26,768 KB
testcase_35 AC 35 ms
26,820 KB
testcase_36 AC 24 ms
26,868 KB
testcase_37 AC 33 ms
26,844 KB
testcase_38 AC 34 ms
26,816 KB
testcase_39 AC 30 ms
26,752 KB
testcase_40 AC 24 ms
26,752 KB
testcase_41 AC 25 ms
26,788 KB
testcase_42 AC 30 ms
26,844 KB
testcase_43 AC 23 ms
26,800 KB
testcase_44 AC 22 ms
27,052 KB
testcase_45 AC 23 ms
26,784 KB
testcase_46 AC 23 ms
26,832 KB
testcase_47 AC 23 ms
26,856 KB
testcase_48 AC 24 ms
26,784 KB
testcase_49 AC 23 ms
26,796 KB
testcase_50 AC 23 ms
26,752 KB
testcase_51 AC 23 ms
26,744 KB
testcase_52 AC 23 ms
26,768 KB
testcase_53 AC 22 ms
26,780 KB
testcase_54 AC 23 ms
26,780 KB
testcase_55 AC 23 ms
26,908 KB
testcase_56 AC 24 ms
26,768 KB
testcase_57 AC 23 ms
26,784 KB
testcase_58 AC 23 ms
26,744 KB
testcase_59 AC 23 ms
26,796 KB
testcase_60 AC 24 ms
26,908 KB
testcase_61 AC 23 ms
26,800 KB
testcase_62 AC 23 ms
26,860 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:34: warning: "MAXN" redefined
 #define MAXN 1000000
 
main.cpp:31: note: this is the location of the previous definition
 #define MAXN 100000
 

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007
#define MAXN 100000

//逆元で二項係数を計算(MODは素数) 前処理O(n),本計算O(1)
#define MAXN 1000000
long long inv[MAXN + 1];//MODを法とする乗法の逆元
long long fact[MAXN + 1];//階乗
long long ifact[MAXN + 1];//階乗の逆元
void init() {
	inv[1] = 1;
	for (int i = 2; i <= MAXN; i++) inv[i] = inv[MOD%i] * (MOD - MOD / i) % MOD;
	fact[0] = ifact[0] = 1;
	for (int i = 1; i <= MAXN; i++) {
		fact[i] = i * fact[i - 1] % MOD;
		ifact[i] = ifact[i - 1] * inv[i] % MOD;
	}
}
long long C(int n, int r) {
	if (n < 0 || r < 0 || r > n)return 0;
	if (r > n / 2)r = n - r;
	return fact[n] * ifact[n - r] % MOD*ifact[r] % MOD;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	init();

	int n;
	cin >> n;
	int ans = 0;
	rep(i,n) {
		long long a;
		cin >> a;
		ans = (ans + a * C(n - 1, i)) % MOD;
	}
	cout << ans << endl;
	

	return 0;
}
0