結果
| 問題 | 
                            No.797 Noelちゃんとピラミッド
                             | 
                    
| コンテスト | |
| ユーザー | 
                             null_mn
                         | 
                    
| 提出日時 | 2019-03-20 21:07:22 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 30 ms / 2,000 ms | 
| コード長 | 2,122 bytes | 
| コンパイル時間 | 1,388 ms | 
| コンパイル使用メモリ | 160,124 KB | 
| 実行使用メモリ | 5,760 KB | 
| 最終ジャッジ日時 | 2024-09-19 00:52:15 | 
| 合計ジャッジ時間 | 4,724 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 60 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;
#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};
//------------------------------------------------------
const ll MAX_N = 100010;
ll fact[MAX_N];
ll fact_inv[MAX_N];
ll pow_mod(ll x, ll y, ll m = MOD) { //x^y mod m
    if (x == 0) return 0;
    ll prod = 1;
    while (y > 0) {
        if (y % 2 == 1) prod = (prod * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return prod % m;
}
void init_fact() {
    fact[0] = fact_inv[0] = 1;
    REP(i, 1, MAX_N) {
        fact[i] = (fact[i - 1] * i) % MOD;
        fact_inv[i] = pow_mod(fact[i], MOD - 2);
    }
}
ll C_mod(ll n, ll r) {
    if (n < r) return 0;
    else return ((fact[n] * fact_inv[n - r]) % MOD * fact_inv[r]) % MOD;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    init_fact();
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += a[i] * C_mod(n - 1, i);
        sum %= MOD;
    }
    cout << sum << endl;
    return 0;
}
            
            
            
        
            
null_mn