結果
| 問題 |
No.797 Noelちゃんとピラミッド
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-16 21:38:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 963 bytes |
| コンパイル時間 | 1,442 ms |
| コンパイル使用メモリ | 159,992 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 08:23:59 |
| 合計ジャッジ時間 | 5,774 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 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(n==0) return 1;
if(n==k) return 1;
else return fa[n]*fa[k]*rfa[n-k];
}
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);
}