結果

問題 No.1102 Remnants
ユーザー coco18000coco18000
提出日時 2020-07-03 21:58:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 168,072 KB
実行使用メモリ 8,384 KB
最終ジャッジ日時 2023-10-17 02:10:54
合計ジャッジ時間 3,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,712 KB
testcase_01 AC 3 ms
7,712 KB
testcase_02 AC 3 ms
7,712 KB
testcase_03 AC 3 ms
7,712 KB
testcase_04 AC 3 ms
7,712 KB
testcase_05 AC 61 ms
8,384 KB
testcase_06 AC 13 ms
7,920 KB
testcase_07 AC 80 ms
8,384 KB
testcase_08 AC 3 ms
7,736 KB
testcase_09 AC 6 ms
7,780 KB
testcase_10 AC 3 ms
7,724 KB
testcase_11 AC 5 ms
7,760 KB
testcase_12 AC 6 ms
7,788 KB
testcase_13 AC 6 ms
7,784 KB
testcase_14 AC 38 ms
8,384 KB
testcase_15 AC 29 ms
8,260 KB
testcase_16 AC 72 ms
8,384 KB
testcase_17 AC 68 ms
8,384 KB
testcase_18 AC 70 ms
8,384 KB
testcase_19 AC 25 ms
8,172 KB
testcase_20 AC 10 ms
7,852 KB
testcase_21 AC 43 ms
8,384 KB
testcase_22 AC 60 ms
8,384 KB
testcase_23 AC 47 ms
8,384 KB
testcase_24 AC 34 ms
8,348 KB
testcase_25 AC 72 ms
8,384 KB
testcase_26 AC 7 ms
7,792 KB
testcase_27 AC 20 ms
8,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];
ll C[200005];
ll I[200005];

ll modpow(ll n, ll r) {
    ll ret = 1;
    ll p = n;
    while (r > 0) {
        if (r & 1)
            ret = (ret * p) % MOD;
        p = (p * p) % MOD;
        r /= 2;
    }
    return ret;
}

ll cmb(ll r) {
    return C[r] * modpow(I[r], MOD - 2) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }

    I[0] = 1;
    C[0] = 1;
    REP(i, N) {
        I[i + 1] = I[i] * (i + 1) % MOD;
        C[i + 1] = C[i] * (K + i + 1) % MOD;
    }

    ll ans = 0;
    REP(i, N) {
        ll l = i + 1;
        ll r = N - i;
        ll c = cmb(l - 1) * cmb(r - 1) % MOD;
        ans += (A[i] * c) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}
0