結果

問題 No.797 Noelちゃんとピラミッド
ユーザー 37zigen
提出日時 2019-03-15 22:33:34
言語 C++11
(gcc 4.8.5)
結果
AC  
実行時間 193 ms
コード長 736 Byte
コンパイル時間 1,160 ms
使用メモリ 5,408 KB
最終ジャッジ日時 2019-04-08 18:13:15

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt AC 126 ms
4,624 KB
002sample.txt AC 126 ms
4,624 KB
003sample.txt AC 127 ms
4,628 KB
LEARGE_case1.txt AC 192 ms
5,404 KB
LEARGE_case2.txt AC 190 ms
5,408 KB
LEARGE_case3.txt AC 191 ms
5,408 KB
LEARGE_case4.txt AC 191 ms
5,404 KB
LEARGE_case5.txt AC 192 ms
5,408 KB
LEARGE_case6.txt AC 191 ms
5,404 KB
LEARGE_case7.txt AC 191 ms
5,404 KB
LEARGE_case8.txt AC 189 ms
5,408 KB
LEARGE_case9.txt AC 189 ms
5,404 KB
LEARGE_case10.txt AC 188 ms
5,404 KB
LEARGE_case11.txt AC 191 ms
5,404 KB
LEARGE_case12.txt AC 191 ms
5,408 KB
LEARGE_case13.txt AC 191 ms
5,408 KB
LEARGE_case14.txt AC 191 ms
5,408 KB
LEARGE_case15.txt AC 191 ms
5,404 KB
LEARGE_case16.txt AC 192 ms
5,404 KB
LEARGE_case17.txt AC 189 ms
5,404 KB
LEARGE_case18.txt AC 193 ms
5,404 KB
LEARGE_case19.txt AC 192 ms
5,408 KB
LEARGE_case20.txt AC 190 ms
5,408 KB
RANDOM_case1.txt AC 172 ms
5,184 KB
RANDOM_case2.txt AC 140 ms
4,796 KB
RANDOM_case3.txt AC 166 ms
5,100 KB
RANDOM_case4.txt AC 164 ms
5,064 KB
RANDOM_case5.txt AC 188 ms
5,388 KB
RANDOM_case6.txt AC 187 ms
5,316 KB
RANDOM_case7.txt AC 136 ms
4,728 KB
RANDOM_case8.txt AC 140 ms
4,788 KB
RANDOM_case9.txt AC 171 ms
5,184 KB
RANDOM_case10.txt AC 146 ms
4,860 KB
RANDOM_case11.txt AC 165 ms
5,080 KB
RANDOM_case12.txt AC 152 ms
4,948 KB
RANDOM_case13.txt AC 190 ms
5,404 KB
RANDOM_case14.txt AC 133 ms
4,704 KB
RANDOM_case15.txt AC 183 ms
5,308 KB
RANDOM_case16.txt AC 186 ms
5,340 KB
RANDOM_case17.txt AC 164 ms
5,072 KB
RANDOM_case18.txt AC 135 ms
4,704 KB
RANDOM_case19.txt AC 136 ms
4,752 KB
RANDOM_case20.txt AC 161 ms
5,056 KB
SMALL_case1.txt AC 126 ms
4,628 KB
SMALL_case2.txt AC 127 ms
4,624 KB
SMALL_case3.txt AC 127 ms
4,624 KB
SMALL_case4.txt AC 129 ms
4,628 KB
SMALL_case5.txt AC 126 ms
4,624 KB
SMALL_case6.txt AC 124 ms
4,624 KB
SMALL_case7.txt AC 126 ms
4,624 KB
SMALL_case8.txt AC 126 ms
4,628 KB
SMALL_case9.txt AC 128 ms
4,628 KB
SMALL_case10.txt AC 126 ms
4,628 KB
SMALL_case11.txt AC 127 ms
4,624 KB
SMALL_case12.txt AC 127 ms
4,628 KB
SMALL_case13.txt AC 125 ms
4,628 KB
SMALL_case14.txt AC 127 ms
4,624 KB
SMALL_case15.txt AC 126 ms
4,628 KB
SMALL_case16.txt AC 126 ms
4,624 KB
SMALL_case17.txt AC 126 ms
4,628 KB
SMALL_case18.txt AC 127 ms
4,624 KB
SMALL_case19.txt AC 127 ms
4,628 KB
SMALL_case20.txt AC 128 ms
4,624 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