結果

問題 No.797 Noelちゃんとピラミッド
ユーザー kk
提出日時 2020-09-19 12:09:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 1,948 ms
コンパイル使用メモリ 199,544 KB
実行使用メモリ 5,204 KB
最終ジャッジ日時 2023-09-05 14:48:56
合計ジャッジ時間 6,694 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
4,896 KB
testcase_01 AC 19 ms
4,924 KB
testcase_02 AC 19 ms
5,064 KB
testcase_03 AC 32 ms
4,888 KB
testcase_04 AC 31 ms
4,912 KB
testcase_05 AC 31 ms
4,956 KB
testcase_06 AC 32 ms
4,912 KB
testcase_07 AC 31 ms
4,984 KB
testcase_08 AC 31 ms
4,900 KB
testcase_09 AC 32 ms
4,904 KB
testcase_10 AC 32 ms
4,980 KB
testcase_11 AC 31 ms
5,108 KB
testcase_12 AC 32 ms
5,108 KB
testcase_13 AC 32 ms
4,916 KB
testcase_14 AC 31 ms
4,964 KB
testcase_15 AC 32 ms
4,900 KB
testcase_16 AC 31 ms
4,932 KB
testcase_17 AC 32 ms
4,888 KB
testcase_18 AC 31 ms
4,940 KB
testcase_19 AC 32 ms
4,900 KB
testcase_20 AC 31 ms
4,956 KB
testcase_21 AC 32 ms
4,956 KB
testcase_22 AC 31 ms
5,200 KB
testcase_23 AC 28 ms
4,980 KB
testcase_24 AC 22 ms
4,908 KB
testcase_25 AC 27 ms
4,924 KB
testcase_26 AC 26 ms
5,204 KB
testcase_27 AC 31 ms
4,960 KB
testcase_28 AC 30 ms
4,968 KB
testcase_29 AC 21 ms
5,140 KB
testcase_30 AC 22 ms
4,940 KB
testcase_31 AC 29 ms
4,908 KB
testcase_32 AC 23 ms
4,920 KB
testcase_33 AC 27 ms
5,008 KB
testcase_34 AC 24 ms
4,980 KB
testcase_35 AC 31 ms
4,908 KB
testcase_36 AC 21 ms
4,928 KB
testcase_37 AC 30 ms
4,936 KB
testcase_38 AC 31 ms
4,936 KB
testcase_39 AC 26 ms
4,988 KB
testcase_40 AC 21 ms
4,940 KB
testcase_41 AC 21 ms
4,952 KB
testcase_42 AC 26 ms
5,044 KB
testcase_43 AC 19 ms
4,988 KB
testcase_44 AC 19 ms
5,072 KB
testcase_45 AC 19 ms
5,020 KB
testcase_46 AC 19 ms
4,936 KB
testcase_47 AC 20 ms
4,900 KB
testcase_48 AC 20 ms
4,944 KB
testcase_49 AC 20 ms
4,944 KB
testcase_50 AC 19 ms
4,908 KB
testcase_51 AC 19 ms
5,016 KB
testcase_52 AC 19 ms
4,936 KB
testcase_53 AC 19 ms
4,924 KB
testcase_54 AC 19 ms
4,984 KB
testcase_55 AC 19 ms
4,920 KB
testcase_56 AC 19 ms
4,928 KB
testcase_57 AC 20 ms
5,108 KB
testcase_58 AC 19 ms
4,900 KB
testcase_59 AC 19 ms
4,908 KB
testcase_60 AC 20 ms
4,936 KB
testcase_61 AC 19 ms
5,036 KB
testcase_62 AC 19 ms
5,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

const long long MOD = 1e9 + 7;

long long f[100000+1];
long long g[100000+1];

long long comb(int n, int r) {
  return f[n] * g[r] % MOD * g[n-r] % MOD;
}

long long modpow(long long x, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1)
      ret = ret * x % mod;
    x = x * x % mod;
    p >>= 1;
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  f[0] = g[0] = 1;
  for (int i = 1; i <= 100000; i++) {
    f[i] = i * f[i-1] % MOD;
    g[i] = modpow(f[i], MOD - 2, MOD);
  }
  
  int n;
  cin >> n;

  long long ret = 0;
  REP (i, n) {
    long long a;
    cin >> a;
    ret += a * comb(n-1, i) % MOD;
    ret %= MOD;
  }
  cout << ret << endl;

  return 0;
}
0