結果

問題 No.797 Noelちゃんとピラミッド
ユーザー oxyshoweroxyshower
提出日時 2020-01-14 18:54:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,004 bytes
コンパイル時間 1,544 ms
コンパイル使用メモリ 167,884 KB
実行使用メモリ 4,940 KB
最終ジャッジ日時 2023-08-26 23:03:31
合計ジャッジ時間 8,389 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 99 ms
4,692 KB
testcase_04 AC 99 ms
4,688 KB
testcase_05 AC 99 ms
4,576 KB
testcase_06 AC 99 ms
4,628 KB
testcase_07 AC 99 ms
4,580 KB
testcase_08 AC 99 ms
4,580 KB
testcase_09 AC 100 ms
4,700 KB
testcase_10 AC 100 ms
4,620 KB
testcase_11 AC 99 ms
4,692 KB
testcase_12 AC 100 ms
4,904 KB
testcase_13 AC 100 ms
4,624 KB
testcase_14 AC 99 ms
4,580 KB
testcase_15 AC 100 ms
4,580 KB
testcase_16 AC 100 ms
4,940 KB
testcase_17 AC 100 ms
4,584 KB
testcase_18 AC 100 ms
4,576 KB
testcase_19 AC 99 ms
4,628 KB
testcase_20 AC 99 ms
4,764 KB
testcase_21 AC 99 ms
4,644 KB
testcase_22 AC 99 ms
4,768 KB
testcase_23 AC 72 ms
4,416 KB
testcase_24 AC 26 ms
4,376 KB
testcase_25 AC 61 ms
4,380 KB
testcase_26 AC 58 ms
4,376 KB
testcase_27 AC 97 ms
4,756 KB
testcase_28 AC 88 ms
4,676 KB
testcase_29 AC 16 ms
4,376 KB
testcase_30 AC 23 ms
4,376 KB
testcase_31 AC 72 ms
4,376 KB
testcase_32 AC 33 ms
4,376 KB
testcase_33 AC 61 ms
4,496 KB
testcase_34 AC 43 ms
4,380 KB
testcase_35 AC 100 ms
4,632 KB
testcase_36 AC 15 ms
4,376 KB
testcase_37 AC 87 ms
4,508 KB
testcase_38 AC 91 ms
4,648 KB
testcase_39 AC 59 ms
4,504 KB
testcase_40 AC 14 ms
4,380 KB
testcase_41 AC 19 ms
4,376 KB
testcase_42 AC 57 ms
4,440 KB
testcase_43 AC 4 ms
4,380 KB
testcase_44 AC 4 ms
4,380 KB
testcase_45 AC 4 ms
4,380 KB
testcase_46 AC 4 ms
4,376 KB
testcase_47 AC 4 ms
4,376 KB
testcase_48 AC 4 ms
4,376 KB
testcase_49 AC 4 ms
4,376 KB
testcase_50 AC 4 ms
4,380 KB
testcase_51 AC 4 ms
4,380 KB
testcase_52 AC 4 ms
4,380 KB
testcase_53 AC 4 ms
4,376 KB
testcase_54 AC 4 ms
4,376 KB
testcase_55 AC 4 ms
4,376 KB
testcase_56 AC 4 ms
4,380 KB
testcase_57 AC 4 ms
4,376 KB
testcase_58 AC 4 ms
4,376 KB
testcase_59 AC 4 ms
4,376 KB
testcase_60 AC 4 ms
4,376 KB
testcase_61 AC 4 ms
4,376 KB
testcase_62 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;
struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; // fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n,int r){ // nCr = n!/r!(n-r)!
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD,MOD-2,MOD) % MOD;
  }

  int mod_pow(int n,int p,int MOD){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int ans = 0;
  comb.init(100001);
  for(int i = 0; i < n; i++){
    ans = (ans + a[i] * comb.nCr(n-1, i)) % MOD;
  }
  cout << ans << endl;

  return 0;
}
0