結果

問題 No.797 Noelちゃんとピラミッド
ユーザー eQeeQe
提出日時 2019-04-16 21:44:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 3,503 ms
コンパイル使用メモリ 159,804 KB
実行使用メモリ 5,928 KB
最終ジャッジ日時 2023-10-22 07:13:53
合計ジャッジ時間 6,609 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 58 ms
5,928 KB
testcase_04 AC 58 ms
5,928 KB
testcase_05 AC 57 ms
5,928 KB
testcase_06 AC 59 ms
5,928 KB
testcase_07 AC 58 ms
5,928 KB
testcase_08 AC 58 ms
5,928 KB
testcase_09 AC 57 ms
5,928 KB
testcase_10 AC 58 ms
5,928 KB
testcase_11 AC 58 ms
5,928 KB
testcase_12 AC 57 ms
5,928 KB
testcase_13 AC 58 ms
5,928 KB
testcase_14 AC 58 ms
5,928 KB
testcase_15 AC 59 ms
5,928 KB
testcase_16 AC 58 ms
5,928 KB
testcase_17 AC 59 ms
5,928 KB
testcase_18 AC 59 ms
5,928 KB
testcase_19 AC 58 ms
5,928 KB
testcase_20 AC 59 ms
5,928 KB
testcase_21 AC 58 ms
5,928 KB
testcase_22 AC 58 ms
5,928 KB
testcase_23 AC 42 ms
5,488 KB
testcase_24 AC 14 ms
4,716 KB
testcase_25 AC 36 ms
5,312 KB
testcase_26 AC 34 ms
5,252 KB
testcase_27 AC 57 ms
5,896 KB
testcase_28 AC 52 ms
5,744 KB
testcase_29 AC 9 ms
4,568 KB
testcase_30 AC 14 ms
4,692 KB
testcase_31 AC 42 ms
5,484 KB
testcase_32 AC 19 ms
4,836 KB
testcase_33 AC 35 ms
5,284 KB
testcase_34 AC 26 ms
5,012 KB
testcase_35 AC 58 ms
5,928 KB
testcase_36 AC 8 ms
4,532 KB
testcase_37 AC 51 ms
5,732 KB
testcase_38 AC 52 ms
5,804 KB
testcase_39 AC 34 ms
5,268 KB
testcase_40 AC 8 ms
4,532 KB
testcase_41 AC 11 ms
4,620 KB
testcase_42 AC 34 ms
5,236 KB
testcase_43 AC 3 ms
4,372 KB
testcase_44 AC 2 ms
4,372 KB
testcase_45 AC 2 ms
4,372 KB
testcase_46 AC 2 ms
4,372 KB
testcase_47 AC 2 ms
4,372 KB
testcase_48 AC 2 ms
4,372 KB
testcase_49 AC 2 ms
4,372 KB
testcase_50 AC 2 ms
4,372 KB
testcase_51 AC 2 ms
4,372 KB
testcase_52 AC 2 ms
4,372 KB
testcase_53 AC 2 ms
4,372 KB
testcase_54 AC 2 ms
4,372 KB
testcase_55 AC 2 ms
4,372 KB
testcase_56 AC 3 ms
4,372 KB
testcase_57 AC 2 ms
4,372 KB
testcase_58 AC 2 ms
4,372 KB
testcase_59 AC 2 ms
4,372 KB
testcase_60 AC 2 ms
4,372 KB
testcase_61 AC 2 ms
4,372 KB
testcase_62 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
}




0