結果

問題 No.797 Noelちゃんとピラミッド
ユーザー zekezeke
提出日時 2019-12-11 19:55:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 2,153 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 96,172 KB
実行使用メモリ 5,568 KB
最終ジャッジ日時 2023-09-06 13:09:21
合計ジャッジ時間 12,163 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
4,916 KB
testcase_01 AC 128 ms
5,076 KB
testcase_02 AC 129 ms
4,960 KB
testcase_03 AC 146 ms
5,352 KB
testcase_04 AC 146 ms
5,356 KB
testcase_05 AC 146 ms
5,396 KB
testcase_06 AC 146 ms
5,444 KB
testcase_07 AC 146 ms
5,488 KB
testcase_08 AC 146 ms
5,440 KB
testcase_09 AC 146 ms
5,352 KB
testcase_10 AC 146 ms
5,452 KB
testcase_11 AC 147 ms
5,404 KB
testcase_12 AC 146 ms
5,400 KB
testcase_13 AC 146 ms
5,396 KB
testcase_14 AC 147 ms
5,344 KB
testcase_15 AC 148 ms
5,440 KB
testcase_16 AC 146 ms
5,364 KB
testcase_17 AC 146 ms
5,524 KB
testcase_18 AC 146 ms
5,412 KB
testcase_19 AC 147 ms
5,440 KB
testcase_20 AC 147 ms
5,568 KB
testcase_21 AC 145 ms
5,348 KB
testcase_22 AC 146 ms
5,364 KB
testcase_23 AC 141 ms
5,148 KB
testcase_24 AC 133 ms
4,936 KB
testcase_25 AC 139 ms
5,148 KB
testcase_26 AC 138 ms
5,132 KB
testcase_27 AC 145 ms
5,356 KB
testcase_28 AC 142 ms
5,420 KB
testcase_29 AC 131 ms
5,012 KB
testcase_30 AC 131 ms
4,984 KB
testcase_31 AC 141 ms
5,128 KB
testcase_32 AC 134 ms
4,912 KB
testcase_33 AC 140 ms
5,088 KB
testcase_34 AC 136 ms
5,128 KB
testcase_35 AC 145 ms
5,352 KB
testcase_36 AC 130 ms
5,064 KB
testcase_37 AC 144 ms
5,444 KB
testcase_38 AC 145 ms
5,340 KB
testcase_39 AC 139 ms
5,172 KB
testcase_40 AC 131 ms
4,996 KB
testcase_41 AC 131 ms
5,040 KB
testcase_42 AC 138 ms
5,172 KB
testcase_43 AC 129 ms
4,984 KB
testcase_44 AC 129 ms
5,000 KB
testcase_45 AC 129 ms
5,032 KB
testcase_46 AC 128 ms
4,916 KB
testcase_47 AC 128 ms
4,952 KB
testcase_48 AC 128 ms
5,196 KB
testcase_49 AC 129 ms
4,936 KB
testcase_50 AC 129 ms
5,164 KB
testcase_51 AC 128 ms
5,016 KB
testcase_52 AC 128 ms
5,000 KB
testcase_53 AC 128 ms
5,204 KB
testcase_54 AC 128 ms
5,060 KB
testcase_55 AC 128 ms
4,936 KB
testcase_56 AC 129 ms
4,916 KB
testcase_57 AC 129 ms
4,920 KB
testcase_58 AC 129 ms
5,024 KB
testcase_59 AC 130 ms
4,920 KB
testcase_60 AC 128 ms
4,968 KB
testcase_61 AC 129 ms
5,020 KB
testcase_62 AC 129 ms
4,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ll modpow(ll a, ll b)
{
    if (b == 0)
        return 1;
    else if (b % 2 == 0)
    {
        ll d = modpow(a, b / 2) % MOD;
        return (d * d) % MOD;
    }
    else
    {
        return (a * modpow(a, b - 1)) % MOD;
    }
}

const int MAX_N = 100010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r)
{
    if (n < r || r < 0)
        return 0;
    return fact[n] * finv[n - r] % MOD * finv[r] % MOD;
}

void calc(int n)
{
    fact[0] = finv[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD - 2);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V vec(n);
    rep(i, n) cin >> vec[i];
    ll sum=0;
    calc(1e5 + 1);
    rep(i,n){
        sum += comb(n - 1, i) * vec[i] % MOD;
        sum %= MOD;
    }
    cout << sum << endl;
}
0