結果

問題 No.1102 Remnants
ユーザー milanis48663220milanis48663220
提出日時 2020-07-03 22:06:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 855 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 83,680 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2023-10-17 03:36:28
合計ジャッジ時間 2,987 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,604 KB
testcase_01 AC 2 ms
5,604 KB
testcase_02 AC 2 ms
5,604 KB
testcase_03 AC 2 ms
5,604 KB
testcase_04 AC 2 ms
5,604 KB
testcase_05 AC 77 ms
8,064 KB
testcase_06 AC 14 ms
6,020 KB
testcase_07 AC 101 ms
8,320 KB
testcase_08 AC 3 ms
5,652 KB
testcase_09 AC 6 ms
5,740 KB
testcase_10 AC 2 ms
5,624 KB
testcase_11 AC 5 ms
5,700 KB
testcase_12 AC 6 ms
5,752 KB
testcase_13 AC 6 ms
5,744 KB
testcase_14 AC 44 ms
7,032 KB
testcase_15 AC 33 ms
6,696 KB
testcase_16 AC 89 ms
8,196 KB
testcase_17 AC 83 ms
8,108 KB
testcase_18 AC 87 ms
8,116 KB
testcase_19 AC 29 ms
6,524 KB
testcase_20 AC 10 ms
5,880 KB
testcase_21 AC 51 ms
7,224 KB
testcase_22 AC 74 ms
7,916 KB
testcase_23 AC 56 ms
7,384 KB
testcase_24 AC 40 ms
6,876 KB
testcase_25 AC 88 ms
8,140 KB
testcase_26 AC 7 ms
5,764 KB
testcase_27 AC 23 ms
6,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

ll N, K;
ll A[200000];
ll cum_sum[200001];

ll inv(ll n){
    if(n == 1) return 1;
    else return MOD-inv(MOD%n)*(MOD/n)%MOD;
}

ll cnt[200005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cum_sum[i+1] = cum_sum[i]+A[i];
    ll ans = 0;
    cnt[1] = 1;
    for(int i = 2; i <= N; i++){
        cnt[i] = (((cnt[i-1]*(K+i-1))%MOD)*inv(i-1))%MOD;
    }
    for(int i = 1; i <= N; i++){
        ll c = (cnt[i]*cnt[N-i+1])%MOD;
        ans += (A[i-1]*c)%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}
0