結果
| 問題 | No.797 Noelちゃんとピラミッド |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-16 21:44:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 59 ms / 2,000 ms |
| コード長 | 975 bytes |
| 記録 | |
| コンパイル時間 | 1,198 ms |
| コンパイル使用メモリ | 159,696 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 08:24:06 |
| 合計ジャッジ時間 | 4,856 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 60 |
ソースコード
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll moP(ll x, ll n) {
ll res=1;
while(n>0) {
if(n&1) moC(res, *, x);
moC(x, *, x);
n>>=1;
}
return res;
}
ll fa[MAX], rfa[MAX];
ll C(ll n, ll k) {
if(k==0) return 1;
if(n==k) return 1;
else return fa[n]*rfa[k]%MOD*rfa[n-k]%MOD;
}
int main(void) {
ll N;
cin >> N;
ll a[MAX];
ll i;
fa[0]=1;
for(i=1; i<=N; i++) {
fa[i]=i*fa[i-1]%MOD;
rfa[i]=moP(fa[i], MOD-2);
}
for(i=0; i<N; i++)
cin >> a[i];
ll ans=0;
for(i=0; i<N; i++)
moC(ans, +, (C(N-1, i)*a[i])%MOD);
pt(ans);
}