結果

問題 No.797 Noelちゃんとピラミッド
ユーザー zelosacezelosace
提出日時 2020-10-18 00:55:20
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 2,073 bytes
コンパイル時間 2,029 ms
コンパイル使用メモリ 202,184 KB
実行使用メモリ 6,244 KB
最終ジャッジ日時 2023-09-28 08:44:30
合計ジャッジ時間 6,011 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,500 KB
testcase_03 AC 16 ms
6,180 KB
testcase_04 AC 17 ms
6,108 KB
testcase_05 AC 16 ms
6,160 KB
testcase_06 AC 16 ms
6,132 KB
testcase_07 AC 16 ms
6,108 KB
testcase_08 AC 16 ms
6,132 KB
testcase_09 AC 15 ms
6,164 KB
testcase_10 AC 15 ms
6,244 KB
testcase_11 AC 15 ms
6,148 KB
testcase_12 AC 15 ms
6,172 KB
testcase_13 AC 15 ms
6,176 KB
testcase_14 AC 15 ms
6,196 KB
testcase_15 AC 15 ms
6,088 KB
testcase_16 AC 15 ms
6,132 KB
testcase_17 AC 16 ms
6,108 KB
testcase_18 AC 16 ms
6,148 KB
testcase_19 AC 16 ms
6,176 KB
testcase_20 AC 15 ms
6,084 KB
testcase_21 AC 15 ms
6,132 KB
testcase_22 AC 14 ms
6,088 KB
testcase_23 AC 11 ms
5,052 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 10 ms
4,832 KB
testcase_26 AC 9 ms
4,784 KB
testcase_27 AC 15 ms
6,104 KB
testcase_28 AC 13 ms
5,600 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 5 ms
4,376 KB
testcase_31 AC 12 ms
5,048 KB
testcase_32 AC 6 ms
4,376 KB
testcase_33 AC 9 ms
4,940 KB
testcase_34 AC 7 ms
4,376 KB
testcase_35 AC 15 ms
6,240 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 14 ms
5,644 KB
testcase_38 AC 14 ms
5,884 KB
testcase_39 AC 9 ms
4,868 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 4 ms
4,380 KB
testcase_42 AC 10 ms
4,780 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,376 KB
testcase_47 AC 2 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 1 ms
4,376 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 1 ms
4,376 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 2 ms
4,376 KB
testcase_57 AC 1 ms
4,376 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }
template<typename T>
bool chmin(T& a,T b){ if(a>b){ a=b;return true; }return false; }

class Combination{
	constexpr static int atcoder_mod = 1000000007;
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}
	ll GetFInv(ll i){
		return finv[i];
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=in();
	vll A=vecin(N);

	Combination comb(N-1);

	ll S=0;
	REP(i,N){
		S += (comb.Caluclation(N-1,i)*A[i])%atcoder_mod;
		S %= atcoder_mod;
	}
	out(S);
	return 0;
}
0