結果

問題 No.797 Noelちゃんとピラミッド
ユーザー shinchan
提出日時 2019-03-15 22:17:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 862 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 158,088 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 21:07:17
合計ジャッジ時間 3,669 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 57
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n==1){
        cout <<a[0]<<endl;
        return 0;
    }
    ll b[n];
    b[0]=1;
    for(int i=1;i<(n+1)/2;i++){
        b[i]=b[i-1]*(n-i)/i;
        b[i]%=mod;
    }
    for(int i=n-1;i>=n/2;i--){
        b[i]=b[n-i-1];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=a[i]*b[i];
        ans%=mod;
    }
    cout <<ans<<endl;
    return 0;
}





0