結果

問題 No.1102 Remnants
ユーザー face4face4
提出日時 2020-07-19 15:48:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 280 ms / 2,000 ms
コード長 795 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 69,500 KB
実行使用メモリ 4,636 KB
最終ジャッジ日時 2023-08-22 10:01:33
合計ジャッジ時間 5,928 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 203 ms
4,384 KB
testcase_06 AC 39 ms
4,384 KB
testcase_07 AC 280 ms
4,636 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 13 ms
4,384 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 13 ms
4,380 KB
testcase_13 AC 13 ms
4,384 KB
testcase_14 AC 119 ms
4,384 KB
testcase_15 AC 91 ms
4,384 KB
testcase_16 AC 237 ms
4,408 KB
testcase_17 AC 222 ms
4,384 KB
testcase_18 AC 245 ms
4,380 KB
testcase_19 AC 85 ms
4,380 KB
testcase_20 AC 27 ms
4,380 KB
testcase_21 AC 148 ms
4,384 KB
testcase_22 AC 209 ms
4,380 KB
testcase_23 AC 160 ms
4,384 KB
testcase_24 AC 115 ms
4,380 KB
testcase_25 AC 248 ms
4,388 KB
testcase_26 AC 16 ms
4,380 KB
testcase_27 AC 65 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;
ll mod = 1e9+7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> sum(n, 0);
    ll comb = 1, a = k, b = 1;
    sum[0] = 1;
    for(int i = 1; i < n; i++){
        comb *= a++;
        comb %= mod;
        comb *= modpow(b++, mod-2, mod);
        comb %= mod;
        sum[i] = (comb+sum[i-1])%mod;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll x;
        cin >> x;
        ans += x*sum[i]%mod*sum[n-1-i]%mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
0