結果

問題 No.995 タピオカオイシクナーレ
ユーザー merom686merom686
提出日時 2020-02-21 21:51:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 892 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 74,908 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:04:58
合計ジャッジ時間 1,693 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 14 ms
5,376 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 15 ms
5,376 KB
testcase_19 AC 15 ms
5,376 KB
testcase_20 AC 15 ms
5,376 KB
testcase_21 AC 15 ms
5,376 KB
testcase_22 AC 14 ms
5,376 KB
testcase_23 AC 14 ms
5,376 KB
testcase_24 AC 14 ms
5,376 KB
testcase_25 AC 14 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}
ll inv(ll n) {
    return powmod(n, P - 2);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    ll k;
    cin >> k;
    
    int p, q;
    cin >> p >> q;

    ll h = inv(2);
    ll x = (P + 1 - p * inv(q) % P * 2 % P) % P;
    x = (h * powmod(x, k) + h) % P;
    ll y = (P + 1 - x) % P;

    ll r = 0;
    for (int i = 0; i < n; i++) {
        ll b;
        cin >> b;

        ll t = i < m ? b * x : b * y;
        r += t % P;
    }

    cout << r % P << endl;

    return 0;
}
0