結果
| 問題 |
No.797 Noelちゃんとピラミッド
|
| コンテスト | |
| ユーザー |
moririn2528_c
|
| 提出日時 | 2019-03-15 21:46:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,067 bytes |
| コンパイル時間 | 750 ms |
| コンパイル使用メモリ | 72,248 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-01 20:43:24 |
| 合計ジャッジ時間 | 5,034 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 60 |
ソースコード
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
LL nCk[100005];
long long int pow_mod(long long int p_a,long long int p_n,long long int p_p=1e9+7){
//p_a^p_n mod p_p
long long int p_b=1,p_t=1;
for(;p_b<=p_n;p_b<<=1);
for(p_b>>=1;p_b>0;p_b>>=1){
p_t*=p_t;
if(p_t>=p_p)p_t%=p_p;
if(p_n&p_b)p_t*=p_a;
if(p_t>=p_p)p_t%=p_p;
}
return p_t;
}
void nCk_mod(int c_n,long long int c_mod=1e9+7){
long long int c_a=1;
nCk[0]=1,nCk[c_n]=1;
for(int i=0;i<c_n/2;i++){
c_a*=(c_n-i);
if(c_a>=c_mod)c_a%=c_mod;
c_a*=pow_mod(i+1,c_mod-2,c_mod);
if(c_a>=c_mod)c_a%=c_mod;
nCk[i+1]=c_a,nCk[c_n-i-1]=c_a;
}
}
int main(){
int n;
LL a,s=0;
cin>>n;
nCk_mod(n-1);
for(int i=0;i<n;i++){
cin>>a;
s+=a*nCk[i];
}
cout<<s<<endl;
return 0;
}
moririn2528_c