結果

問題 No.1102 Remnants
ユーザー dekomori_sanaedekomori_sanae
提出日時 2022-03-03 17:23:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 1,384 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 84,288 KB
実行使用メモリ 6,284 KB
最終ジャッジ日時 2023-09-24 13:04:17
合計ジャッジ時間 3,131 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,940 KB
testcase_01 AC 5 ms
4,880 KB
testcase_02 AC 5 ms
4,992 KB
testcase_03 AC 5 ms
5,204 KB
testcase_04 AC 6 ms
4,992 KB
testcase_05 AC 39 ms
5,980 KB
testcase_06 AC 16 ms
4,940 KB
testcase_07 AC 82 ms
6,284 KB
testcase_08 AC 6 ms
4,960 KB
testcase_09 AC 8 ms
4,944 KB
testcase_10 AC 6 ms
4,948 KB
testcase_11 AC 7 ms
4,976 KB
testcase_12 AC 8 ms
5,060 KB
testcase_13 AC 8 ms
4,996 KB
testcase_14 AC 31 ms
5,404 KB
testcase_15 AC 25 ms
5,168 KB
testcase_16 AC 55 ms
5,904 KB
testcase_17 AC 52 ms
6,040 KB
testcase_18 AC 72 ms
5,852 KB
testcase_19 AC 28 ms
5,104 KB
testcase_20 AC 13 ms
5,008 KB
testcase_21 AC 45 ms
5,560 KB
testcase_22 AC 62 ms
5,780 KB
testcase_23 AC 49 ms
5,368 KB
testcase_24 AC 37 ms
5,248 KB
testcase_25 AC 73 ms
5,964 KB
testcase_26 AC 9 ms
4,980 KB
testcase_27 AC 23 ms
4,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

const ll MAX = 200010;

ll inv[MAX];  // inv[i] : iの逆数のmod

void init() {
    inv[0] = inv[1] = 1;
    for(ll i = 1; i < MAX; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
    }
}

int main() {
    ll n, k;
    cin >> n >> k;

    init();

    vl C(n);  // C[i] : Comb(k + i, k)
    C[0] = 1;
    exrep(i, 1, n-1) {
        C[i] = (k + i) * inv[i] % mod * C[i-1] % mod;
    }

    ll ans = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        ans += a * C[i] % mod * C[n - 1 - i];
        ans %= mod;
    }

    out(ans);
    re0;
}
0