結果

問題 No.995 タピオカオイシクナーレ
ユーザー okok
提出日時 2020-02-21 22:14:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,223 bytes
コンパイル時間 1,181 ms
コンパイル使用メモリ 83,128 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-07-30 06:25:32
合計ジャッジ時間 2,228 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

// #define int long long
#define int __int128
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

long long power(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	long long N, M, K, p, q;
	int	P, P2;
	int E, O;
	int ans = 0;
	vector<long long> b;
	
	cin>>N>>M>>K>>p>>q;
	
	b.resize(N);
	
	P = (int)p * power(q, MOD-2) % MOD;
	P2 = (int)(q - p + MOD) % MOD * power(q, MOD-2) % MOD;
	
	swap(P, P2);
	
	E = ((int)1 + power((P + MOD - P2)%MOD, K))%MOD;
	E *= (int)power(2, MOD-2);
	E %= MOD;
	
	O = ((int)1 + MOD - power((P + MOD - P2)%MOD, K))%MOD;
	O *= (int)power(2, MOD-2);
	O %= MOD;
	
	
	for(int i = 0; i < N; i++) {
		cin>>b[i];
		
		if(i < M) {
			ans += (int)b[i] * E%MOD;
		} else {
			ans += (int)b[i] * O%MOD;
		}
		
		ans %= MOD;
	}
	
	cout<<(long long)ans<<endl;
	
	
	return 0;
}
0