結果
| 問題 |
No.995 タピオカオイシクナーレ
|
| コンテスト | |
| ユーザー |
utouto97
|
| 提出日時 | 2020-02-21 22:33:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,893 bytes |
| コンパイル時間 | 1,869 ms |
| コンパイル使用メモリ | 171,456 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-08 22:53:14 |
| 合計ジャッジ時間 | 3,337 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> using V = vector<T>;
using P = pair<int, int>;
/*
* */
const int mod = 1e9+7;
int mpow(int a, int b)
{
if(b == 0) return 1;
return mpow(a*a%mod, b/2)*(b%2?a:1)%mod;
}
int e[42][2];
signed main() {
int n, m, k, p, q;
cin >> n >> m >> k >> p >> q;
V<int> b(n);
rep(i, 0, n) cin >> b[i];
e[0][0] = p*mpow(q, mod-2)%mod;
e[0][1] = (1-p*mpow(q, mod-2)%mod+mod)%mod;
rep(i, 1, 42){
int x = e[i-1][0];
int y = e[i-1][1];
e[i][0] = (x*x%mod + y*y%mod)%mod;
e[i][1] = 2*x*y%mod;
// cout << x << " -:- " << y << endl;
}
V<int> cnt(2, -1);
int i = 0;
while(k){
if(k%2){
int x = e[i][0];
int y = e[i][1];
if(cnt[0] == -1){
cnt[0] = x;
cnt[1] = y;
}else{
int t = cnt[0];
int s = cnt[1];
cnt[0] = (x*t%mod + y*s%mod)%mod;
cnt[1] = (x*s%mod + y*t%mod)%mod;
// cout << x*t%mod << endl;
// cout << x*s%mod << endl;
// cout << y*t%mod << endl;
// cout << y*s%mod << endl;
// cout << x << ":" << y << " ";
// cout << cnt[0] << " --- " << cnt[1] << endl;
}
}
k /= 2;
i++;
}
V<int> sum(2);
rep(i, 0, m) sum[0] += b[i];
rep(i, m, n) sum[1] += b[i];
int ans = 0;
(ans += sum[0]*cnt[0]%mod) %= mod;
(ans += sum[1]*cnt[1]%mod) %= mod;
cout << ans << endl;
// cout << (ans*4%mod) << endl;
// cout << cnt[0] << " - " << cnt[1] << endl;
// cout << sum[0] << " - " << sum[1] << endl;
return 0;
}
utouto97