結果

問題 No.797 Noelちゃんとピラミッド
ユーザー plcherrimplcherrim
提出日時 2019-03-15 21:27:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 6,725 bytes
コンパイル時間 1,596 ms
コンパイル使用メモリ 169,896 KB
実行使用メモリ 16,600 KB
最終ジャッジ日時 2023-09-14 12:57:20
合計ジャッジ時間 8,459 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
15,292 KB
testcase_01 AC 31 ms
15,404 KB
testcase_02 AC 34 ms
15,332 KB
testcase_03 AC 111 ms
16,524 KB
testcase_04 AC 111 ms
16,548 KB
testcase_05 AC 112 ms
16,432 KB
testcase_06 AC 112 ms
16,412 KB
testcase_07 AC 113 ms
16,512 KB
testcase_08 AC 110 ms
16,524 KB
testcase_09 AC 110 ms
16,516 KB
testcase_10 AC 111 ms
16,472 KB
testcase_11 AC 111 ms
16,436 KB
testcase_12 AC 111 ms
16,512 KB
testcase_13 AC 113 ms
16,492 KB
testcase_14 AC 113 ms
16,488 KB
testcase_15 AC 111 ms
16,532 KB
testcase_16 AC 111 ms
16,412 KB
testcase_17 AC 112 ms
16,576 KB
testcase_18 AC 110 ms
16,456 KB
testcase_19 AC 111 ms
16,520 KB
testcase_20 AC 111 ms
16,600 KB
testcase_21 AC 113 ms
16,412 KB
testcase_22 AC 113 ms
16,428 KB
testcase_23 AC 90 ms
16,256 KB
testcase_24 AC 49 ms
15,472 KB
testcase_25 AC 80 ms
15,980 KB
testcase_26 AC 78 ms
15,992 KB
testcase_27 AC 109 ms
16,472 KB
testcase_28 AC 102 ms
16,556 KB
testcase_29 AC 42 ms
15,464 KB
testcase_30 AC 50 ms
15,548 KB
testcase_31 AC 90 ms
16,172 KB
testcase_32 AC 56 ms
15,496 KB
testcase_33 AC 78 ms
15,908 KB
testcase_34 AC 64 ms
15,760 KB
testcase_35 AC 112 ms
16,580 KB
testcase_36 AC 39 ms
15,444 KB
testcase_37 AC 101 ms
16,172 KB
testcase_38 AC 105 ms
16,520 KB
testcase_39 AC 77 ms
15,908 KB
testcase_40 AC 40 ms
15,440 KB
testcase_41 AC 44 ms
15,592 KB
testcase_42 AC 77 ms
15,944 KB
testcase_43 AC 32 ms
15,324 KB
testcase_44 AC 31 ms
15,304 KB
testcase_45 AC 31 ms
15,324 KB
testcase_46 AC 31 ms
15,380 KB
testcase_47 AC 32 ms
15,592 KB
testcase_48 AC 30 ms
15,412 KB
testcase_49 AC 31 ms
15,504 KB
testcase_50 AC 31 ms
15,328 KB
testcase_51 AC 31 ms
15,384 KB
testcase_52 AC 31 ms
15,376 KB
testcase_53 AC 30 ms
15,360 KB
testcase_54 AC 30 ms
15,316 KB
testcase_55 AC 30 ms
15,408 KB
testcase_56 AC 31 ms
15,364 KB
testcase_57 AC 31 ms
15,300 KB
testcase_58 AC 32 ms
15,320 KB
testcase_59 AC 32 ms
15,404 KB
testcase_60 AC 32 ms
15,328 KB
testcase_61 AC 31 ms
15,332 KB
testcase_62 AC 32 ms
15,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
int mpow(int v, ll a) {
	ll x = v, n = a, res = 1;
	while ( n ) {
		if ( n & 1 )res = res*x%MOD;
		x = x*x%MOD;
		n >>= 1;
	}
	return res;
}

class mint {
private:
	ll v;
public:
	static ll mod(ll a) { return ( a % MOD + MOD ) % MOD; }
	mint(ll a = 0) { this->v = mod(a); };
	mint(const mint &a) { v = a.v; }
	mint operator+(const mint &a) { return mint(v + a.v); }
	mint operator+(const ll a) { return mint(v + a % MOD); }
	mint operator+(const signed a) { return mint(v + a % MOD); }
	friend mint operator+(const ll a, const mint &b) { return mint(a % MOD + b.v); }
	void operator+=(const mint &a) { v = ( v + a.v ) % MOD; }
	void operator+=(const ll a) { v = mod(v + a % MOD); }
	void operator+=(const signed a) { v = mod(v + a % MOD); }
	friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); }
	mint operator-(const mint &a) { return mint(v - a.v); }
	mint operator-(const ll a) { return mint(v - a % MOD); }
	mint operator-(const signed a) { return mint(v - a % MOD); }
	friend mint operator-(const ll a, const mint &b) { return mint(a % MOD - b.v); }
	void operator-=(const mint &a) { v = mod(v - a.v); }
	void operator-=(const ll a) { v = mod(v - a % MOD); }
	void operator-=(const signed a) { v = mod(v - a % MOD); }
	friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); }
	mint operator*(const mint &a) { return mint(v * a.v); }
	mint operator*(const ll a) { return mint(v * ( a % MOD )); }
	mint operator*(const signed a) { return mint(v * ( a % MOD )); }
	friend mint operator*(const ll a, const mint &b) { return mint(a % MOD * b.v); }
	void operator*=(const mint &a) { v = ( v * a.v ) % MOD; }
	void operator*=(const ll a) { v = mod(v * ( a % MOD )); }
	void operator*=(const signed a) { v = mod(v * ( a % MOD )); }
	friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); }
	mint operator/(const mint &a);
	mint operator/(const ll a);
	mint operator/(const signed a);
	friend mint operator/(const ll a, const mint &b);
	void operator/=(const mint &a);
	void operator/=(const ll a);
	void operator/=(const signed a);
	friend void operator/=(ll &a, const mint &b);
	mint operator^(const mint &a) { return mpow(v, a.v); };
	mint operator^(const ll a) { return mpow(v, a); };
	mint operator^(const signed a) { return mpow(v, a); };
	friend mint operator^(const ll a, const mint &b) { return mpow(a, b.v); };
	void operator^=(const mint &a) { v = mpow(v, a.v); }
	void operator^=(const ll a) { v = mpow(v, a); }
	void operator^=(const signed a) { v = mpow(v, a); }
	mint operator+() { return *this; }
	mint operator++() { v++; return *this; }
	mint operator++(signed d) { mint res = *this; v++; return res;}
	mint operator-() { return operator*(-1); }
	mint operator--() { v--; return *this; }
	mint operator--(signed d) { mint res = *this; v--; return res;}
	bool operator==(mint &a) { return v == a.v; }
	bool operator==(signed a) { return v == a; }
	friend bool operator==(signed a, mint &b) { return a == b.v; }
	bool operator!=(mint &a) { return v != a.v; }
	bool operator!=(signed a) { return v != a; }
	friend bool operator!=(signed a, mint &b) { return a != b.v; }
	operator int() { return v; }
};
const int setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];
void setMod() {
	fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
	for ( int i = 2; i < setModMax; i++ ) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * ( MOD / i ) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
mint minv(ll a) {
	if ( fac[0] == 0 )setMod();
	if ( a < setModMax ) return inv[a];
	a %= MOD;
	ll b = MOD, x = 1, y = 0;
	while ( b ) {
		ll t = a / b;
		a -= t*b; swap(a, b);
		x -= t*y; swap(x, y);
	}
	return ( x % MOD + MOD ) % MOD;
}

mint mint::operator/(const mint &a) { return mint(v * minv(a.v)); }
mint mint::operator/(const ll a) { return mint(v * minv(a)); }
mint mint::operator/(const signed a) { return mint(v * minv(a)); }
mint operator/(const ll a, const mint &b) { return mint(a % MOD * minv(b.v)); }
void mint::operator/=(const mint &a) { v = ( v * minv(a.v) ) % MOD; }
void mint::operator/=(const ll a) { v = mod(v * minv(a)); }
void mint::operator/=(const signed a) { v = mod(v * minv(a)); }
void operator/=(ll &a, const mint &b) { a = mint::mod(a % MOD * minv(b.v)); }
auto&operator>>(istream&is,mint&t){ll a; cin>>a; t=a; return is;};
auto&operator<<(ostream&os,mint&t){cout<<((int)t); return os;};
mint operator"" _m(unsigned long long a){return mint(a);}
using vm=vector<mint>;
using vvm=vector<vm>;
mint nCr(ll n,ll r){
	static vm f;
	if(f.size()<n+1){
		f.assign(n+1,1);
		range(i,2,n+1)f[i]=f[i-1]*i;
	}
	return f[n]/f[r]/f[n-r];
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vm a(n);
	cin>>a;
	mint ans=0;
	rep(i,n){
		ans+=a[i]*nCr(n-1,i);
	}
	puta(ans);
	return 0;
}
0