結果

問題 No.995 タピオカオイシクナーレ
ユーザー kappybarkappybar
提出日時 2020-04-14 21:51:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,177 bytes
コンパイル時間 1,721 ms
コンパイル使用メモリ 164,388 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 18:12:45
合計ジャッジ時間 3,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 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,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 43 ms
6,944 KB
testcase_17 AC 43 ms
6,940 KB
testcase_18 AC 43 ms
6,940 KB
testcase_19 AC 43 ms
6,940 KB
testcase_20 AC 43 ms
6,940 KB
testcase_21 AC 42 ms
6,944 KB
testcase_22 AC 43 ms
6,940 KB
testcase_23 AC 42 ms
6,940 KB
testcase_24 AC 43 ms
6,940 KB
testcase_25 AC 42 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

long long modpow(long long a, long long b,long long mod){
        bitset<60> bit(b);
        string s = bit.to_string();
        long long ret = 1;
        for (int i = 0;i< s.length(); ++i){
                ret = (ret * ret) % mod;
                if(s[i]-'0') ret = (ret * a) % mod;
        }
        return ret;
}

long long inverse(long long x,long long mod){
    return modpow(x,mod-2,mod);
}

int main(){
    ll n,m,k,p,q;
    cin >> n >> m >> k >> p >> q;
    ll A = 0,B = 0;
    rep(i,m){
        ll a;cin >> a;
        A = (A + a)%MOD;
    }
    rep(i,n-m){
        ll b;cin >> b;
        B = (B + b)%MOD;
    }
    ll C = modpow(q,k,MOD);
    ll D = modpow(q-2*p+MOD,k,MOD);
    ll X = ((((A+B)%MOD) * C)%MOD + ((A-B+MOD)%MOD * D)%MOD)%MOD;
    ll Y = (2 * C)%MOD;
    ll R = (X * inverse(Y,MOD))%MOD;
    /*cout << A << endl;
    cout << B << endl;
    cout << C << endl;
    cout << D  << endl;
    cout << X << endl;
    cout << Y << endl;*/
    cout << R << endl;
    return 0;
}
0