結果

問題 No.995 タピオカオイシクナーレ
ユーザー yakkiyakki
提出日時 2020-02-22 15:30:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 1,501 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 123,892 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 23:11:44
合計ジャッジ時間 3,479 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 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 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 95 ms
5,376 KB
testcase_17 AC 116 ms
5,376 KB
testcase_18 AC 104 ms
5,376 KB
testcase_19 AC 103 ms
5,376 KB
testcase_20 AC 101 ms
5,376 KB
testcase_21 AC 124 ms
5,376 KB
testcase_22 AC 102 ms
5,376 KB
testcase_23 AC 114 ms
5,376 KB
testcase_24 AC 104 ms
5,376 KB
testcase_25 AC 92 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(){
	ll N,M,K,p,q; cin >> N >> M >> K >> p >> q;
	vector<ll> b(N);
	rep(i,N) cin >> b[i];
	ll ans = 0;
	rep(i,N){
	    ll now;
		if(i <= M-1){
			now = ((1+modpow(((q-2*p)*modinv(q,MOD)%MOD+MOD)%MOD,K,MOD))%MOD+MOD)%MOD*modinv(2,MOD)%MOD;
		}
		else{
			now = ((1-modpow(((q-2*p)*modinv(q,MOD)%MOD+MOD)%MOD,K,MOD))%MOD+MOD)%MOD*modinv(2,MOD)%MOD;
		}
		ans += now*b[i]%MOD;
		ans %= MOD;
	}
	cout << ans << endl;

}

0