結果

問題 No.797 Noelちゃんとピラミッド
ユーザー 37zigen
提出日時 2019-03-15 22:33:34
言語 C++11
(gcc 4.8.5)
結果
AC  
実行時間 200 ms
コード長 736 Byte
コンパイル時間 982 ms
使用メモリ 7,100 KB
最終ジャッジ日時 2019-06-28 11:31:02

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
001sample.txt AC 130 ms
6,872 KB
002sample.txt AC 126 ms
6,872 KB
003sample.txt AC 126 ms
6,872 KB
LEARGE_case1.txt AC 189 ms
6,872 KB
LEARGE_case2.txt AC 189 ms
6,872 KB
LEARGE_case3.txt AC 190 ms
6,868 KB
LEARGE_case4.txt AC 193 ms
6,872 KB
LEARGE_case5.txt AC 189 ms
6,868 KB
LEARGE_case6.txt AC 189 ms
6,868 KB
LEARGE_case7.txt AC 191 ms
6,868 KB
LEARGE_case8.txt AC 194 ms
6,868 KB
LEARGE_case9.txt AC 191 ms
6,868 KB
LEARGE_case10.txt AC 191 ms
6,868 KB
LEARGE_case11.txt AC 190 ms
6,868 KB
LEARGE_case12.txt AC 191 ms
6,872 KB
LEARGE_case13.txt AC 191 ms
6,868 KB
LEARGE_case14.txt AC 190 ms
6,872 KB
LEARGE_case15.txt AC 190 ms
6,868 KB
LEARGE_case16.txt AC 200 ms
6,872 KB
LEARGE_case17.txt AC 197 ms
6,868 KB
LEARGE_case18.txt AC 191 ms
6,872 KB
LEARGE_case19.txt AC 189 ms
6,868 KB
LEARGE_case20.txt AC 189 ms
6,868 KB
RANDOM_case1.txt AC 172 ms
6,868 KB
RANDOM_case2.txt AC 140 ms
6,872 KB
RANDOM_case3.txt AC 164 ms
6,868 KB
RANDOM_case4.txt AC 162 ms
7,100 KB
RANDOM_case5.txt AC 188 ms
6,872 KB
RANDOM_case6.txt AC 182 ms
6,872 KB
RANDOM_case7.txt AC 136 ms
6,868 KB
RANDOM_case8.txt AC 140 ms
6,868 KB
RANDOM_case9.txt AC 176 ms
6,868 KB
RANDOM_case10.txt AC 145 ms
6,872 KB
RANDOM_case11.txt AC 162 ms
6,872 KB
RANDOM_case12.txt AC 152 ms
6,868 KB
RANDOM_case13.txt AC 186 ms
6,868 KB
RANDOM_case14.txt AC 133 ms
6,872 KB
RANDOM_case15.txt AC 180 ms
7,096 KB
RANDOM_case16.txt AC 184 ms
6,872 KB
RANDOM_case17.txt AC 162 ms
6,872 KB
RANDOM_case18.txt AC 133 ms
6,872 KB
RANDOM_case19.txt AC 136 ms
6,872 KB
RANDOM_case20.txt AC 161 ms
6,872 KB
SMALL_case1.txt AC 131 ms
6,868 KB
SMALL_case2.txt AC 125 ms
6,868 KB
SMALL_case3.txt AC 126 ms
6,872 KB
SMALL_case4.txt AC 127 ms
6,868 KB
SMALL_case5.txt AC 126 ms
7,100 KB
SMALL_case6.txt AC 126 ms
6,872 KB
SMALL_case7.txt AC 127 ms
6,868 KB
SMALL_case8.txt AC 125 ms
6,868 KB
SMALL_case9.txt AC 126 ms
6,872 KB
SMALL_case10.txt AC 124 ms
6,872 KB
SMALL_case11.txt AC 127 ms
6,868 KB
SMALL_case12.txt AC 127 ms
6,872 KB
SMALL_case13.txt AC 126 ms
6,868 KB
SMALL_case14.txt AC 132 ms
6,868 KB
SMALL_case15.txt AC 125 ms
6,872 KB
SMALL_case16.txt AC 125 ms
6,868 KB
SMALL_case17.txt AC 126 ms
6,872 KB
SMALL_case18.txt AC 128 ms
6,872 KB
SMALL_case19.txt AC 124 ms
6,868 KB
SMALL_case20.txt AC 127 ms
6,868 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