結果

問題 No.797 Noelちゃんとピラミッド
ユーザー rhincodon66
提出日時 2019-03-15 22:40:49
言語 C++14
(gcc 8.2.0)
結果
WA   .
実行時間 -
コード長 760 Byte
コンパイル時間 1,319 ms
使用メモリ 3,668 KB
最終ジャッジ日時 2019-05-07 13:39:38

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt AC 18 ms
3,088 KB
002sample.txt AC 19 ms
3,088 KB
003sample.txt AC 19 ms
3,088 KB
LEARGE_case1.txt WA -
LEARGE_case2.txt WA -
LEARGE_case3.txt WA -
LEARGE_case4.txt WA -
LEARGE_case5.txt WA -
LEARGE_case6.txt WA -
LEARGE_case7.txt WA -
LEARGE_case8.txt WA -
LEARGE_case9.txt WA -
LEARGE_case10.txt WA -
LEARGE_case11.txt WA -
LEARGE_case12.txt WA -
LEARGE_case13.txt WA -
LEARGE_case14.txt WA -
LEARGE_case15.txt WA -
LEARGE_case16.txt WA -
LEARGE_case17.txt WA -
LEARGE_case18.txt WA -
LEARGE_case19.txt WA -
LEARGE_case20.txt WA -
RANDOM_case1.txt WA -
RANDOM_case2.txt WA -
RANDOM_case3.txt WA -
RANDOM_case4.txt WA -
RANDOM_case5.txt WA -
RANDOM_case6.txt WA -
RANDOM_case7.txt WA -
RANDOM_case8.txt WA -
RANDOM_case9.txt WA -
RANDOM_case10.txt WA -
RANDOM_case11.txt WA -
RANDOM_case12.txt WA -
RANDOM_case13.txt WA -
RANDOM_case14.txt WA -
RANDOM_case15.txt WA -
RANDOM_case16.txt WA -
RANDOM_case17.txt WA -
RANDOM_case18.txt WA -
RANDOM_case19.txt WA -
RANDOM_case20.txt WA -
SMALL_case1.txt WA -
SMALL_case2.txt WA -
SMALL_case3.txt WA -
SMALL_case4.txt WA -
SMALL_case5.txt WA -
SMALL_case6.txt WA -
SMALL_case7.txt WA -
SMALL_case8.txt WA -
SMALL_case9.txt WA -
SMALL_case10.txt WA -
SMALL_case11.txt WA -
SMALL_case12.txt WA -
SMALL_case13.txt WA -
SMALL_case14.txt WA -
SMALL_case15.txt WA -
SMALL_case16.txt WA -
SMALL_case17.txt WA -
SMALL_case18.txt WA -
SMALL_case19.txt WA -
SMALL_case20.txt WA -
テストケース一括ダウンロード

ソースコード

diff #
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const ll mod=1000000007;

ll f[100001],rf[100001];

ll inv(ll x){
	ll ret=1;
	ll k=mod-2;
	ll y=x;
	while(k){
		if(k&1) ret=ret*y%mod;
		y=y*y%mod;
		k/=2;
	}
	return ret;
}

void init(){
	f[0]=1;
	for(int i=1;i<=100000;++i) f[i]=f[i-1]*i%mod;
	rep(i,100001) rf[i]=inv(f[i]);
}

ll calc(int n,int k){
	ll a=f[n];
	ll b=rf[n-k];
	ll c=rf[k];
	ll bc=b*c%mod;
	return a*bc%mod;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans=0;
	init();
	rep(i,n){
		ans+=calc(n-1,i)*a.at(i)%mod;
	}
	cout << ans << endl;
}
0