結果

問題 No.995 タピオカオイシクナーレ
ユーザー ミドリムシミドリムシ
提出日時 2020-02-23 22:52:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,180 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 163,216 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 05:44:30
合計ジャッジ時間 3,304 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()

lint power(lint base, lint exponent, lint module){
    if(exponent % 2){
        return power(base, exponent - 1, module) * base % module;
    }else if(exponent){
        lint root_ans = power(base, exponent / 2, module);
        return root_ans * root_ans % module;
    }else{
        return 1;
    }
}

int main(){
    int N, M;
    lint K;
    cin >> N >> M >> K;
    lint p, q;
    cin >> p >> q;
    lint r = p * power(q, mod - 2, mod) % mod;
    
    lint milk_tea = 0;
    for(int i = 0; i < M; i++){
        lint b;
        cin >> b;
        milk_tea += b;
    }
    milk_tea %= mod;
    lint kitchen = 0;
    for(int i = 0; i < N - M; i++){
        lint b;
        cin >> b;
        kitchen += b;
    }
    kitchen %= mod;
    
    lint probability_milk = (1 + power((1 - r * 2 + mod * 2) % mod, K, mod)) * 500000004ll % mod;
    lint probability_kitchen = (1 - power((1 - r * 2 + mod * 2) % mod, K, mod) + mod) * 500000004ll % mod;
    cout << (milk_tea * probability_milk % mod + kitchen * probability_kitchen % mod) % mod << endl;
}
0