結果

問題 No.797 Noelちゃんとピラミッド
ユーザー 37zigen37zigen
提出日時 2019-03-15 22:33:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 3,207 ms
コンパイル使用メモリ 144,180 KB
実行使用メモリ 7,544 KB
最終ジャッジ日時 2023-09-14 13:48:38
合計ジャッジ時間 12,678 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
6,544 KB
testcase_01 AC 119 ms
6,744 KB
testcase_02 AC 118 ms
6,492 KB
testcase_03 AC 161 ms
7,264 KB
testcase_04 AC 161 ms
7,276 KB
testcase_05 AC 162 ms
7,276 KB
testcase_06 AC 161 ms
7,276 KB
testcase_07 AC 162 ms
7,204 KB
testcase_08 AC 161 ms
7,200 KB
testcase_09 AC 160 ms
7,212 KB
testcase_10 AC 162 ms
7,212 KB
testcase_11 AC 161 ms
7,292 KB
testcase_12 AC 162 ms
7,544 KB
testcase_13 AC 161 ms
7,212 KB
testcase_14 AC 162 ms
7,372 KB
testcase_15 AC 161 ms
7,204 KB
testcase_16 AC 162 ms
7,204 KB
testcase_17 AC 161 ms
7,204 KB
testcase_18 AC 161 ms
7,204 KB
testcase_19 AC 161 ms
7,348 KB
testcase_20 AC 160 ms
7,312 KB
testcase_21 AC 161 ms
7,420 KB
testcase_22 AC 161 ms
7,272 KB
testcase_23 AC 149 ms
6,980 KB
testcase_24 AC 127 ms
6,604 KB
testcase_25 AC 144 ms
6,960 KB
testcase_26 AC 143 ms
7,156 KB
testcase_27 AC 164 ms
7,520 KB
testcase_28 AC 156 ms
7,128 KB
testcase_29 AC 124 ms
6,536 KB
testcase_30 AC 126 ms
6,692 KB
testcase_31 AC 149 ms
7,196 KB
testcase_32 AC 130 ms
6,772 KB
testcase_33 AC 141 ms
6,988 KB
testcase_34 AC 135 ms
6,816 KB
testcase_35 AC 161 ms
7,376 KB
testcase_36 AC 122 ms
6,588 KB
testcase_37 AC 156 ms
7,168 KB
testcase_38 AC 158 ms
7,144 KB
testcase_39 AC 144 ms
6,872 KB
testcase_40 AC 123 ms
6,588 KB
testcase_41 AC 125 ms
6,552 KB
testcase_42 AC 142 ms
6,936 KB
testcase_43 AC 118 ms
6,436 KB
testcase_44 AC 119 ms
6,424 KB
testcase_45 AC 119 ms
6,420 KB
testcase_46 AC 119 ms
6,592 KB
testcase_47 AC 118 ms
6,672 KB
testcase_48 AC 118 ms
6,556 KB
testcase_49 AC 118 ms
6,500 KB
testcase_50 AC 118 ms
6,600 KB
testcase_51 AC 117 ms
6,548 KB
testcase_52 AC 117 ms
6,644 KB
testcase_53 AC 118 ms
6,440 KB
testcase_54 AC 116 ms
6,500 KB
testcase_55 AC 118 ms
6,508 KB
testcase_56 AC 117 ms
6,504 KB
testcase_57 AC 118 ms
6,424 KB
testcase_58 AC 118 ms
6,500 KB
testcase_59 AC 119 ms
6,424 KB
testcase_60 AC 117 ms
6,440 KB
testcase_61 AC 116 ms
6,536 KB
testcase_62 AC 118 ms
6,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

long long a[100000];
long long mod=1e9+7;

long long fac[200000];
long long ifac[200000];

long long pow(long long a,long long n){
  long long ret=1;
  for(;n>0;n>>=1,a=a*a%mod){
    if(n%2==1){
      ret=ret*a%mod;
    }
  }
  return ret;
}

long long inv(long long a){
  return pow(a,mod-2);
}

long long comb(int n,int k){
  return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}

int main(){
  fac[0]=ifac[0]=1;
  for(int i=1;i<200000;++i){
    fac[i]=fac[i-1]*i%mod;
  }
  for(int i=1;i<200000;++i){
    ifac[i]=inv(fac[i]);
  }
  
  int n;
  std::cin>>n;
  
  long long sum=0;

  for(int i=0;i<n;++i){
    std::cin>>a[i];
    sum=(sum+comb(n-1,i)*a[i]%mod)%mod;
  }

  std::cout<<sum<<std::endl;
  

  return 0;
}


0