結果

問題 No.995 タピオカオイシクナーレ
ユーザー batsumarubatsumaru
提出日時 2020-02-21 21:47:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 1,205 bytes
コンパイル時間 1,544 ms
コンパイル使用メモリ 167,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:04:27
合計ジャッジ時間 4,841 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 224 ms
5,376 KB
testcase_17 AC 243 ms
5,376 KB
testcase_18 AC 238 ms
5,376 KB
testcase_19 AC 229 ms
5,376 KB
testcase_20 AC 231 ms
5,376 KB
testcase_21 AC 237 ms
5,376 KB
testcase_22 AC 232 ms
5,376 KB
testcase_23 AC 232 ms
5,376 KB
testcase_24 AC 238 ms
5,376 KB
testcase_25 AC 213 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const int MOD = 1000000007;

ll modpow(ll a, ll b, ll m) {
  if (b == 0) return 1;
  ll ret;
  if (b % 2 == 0) {
    ll t = modpow(a, b / 2, m) % m;
    ret = t * t % m;
  } else {
    ll t = modpow(a, (b - 1) / 2, m) % m;
    ret = a * t % m * t % m;
  }
  ret %= m;
  return ret;
}

ll inv(ll a) { return modpow(a, MOD - 2, MOD); }

int main() {
  ll N, M, K, p, q;
  cin >> N >> M >> K >> p >> q;
  M--;
  vector<ll> b(N);
  REP(i, N) { cin >> b[i]; }
  ll r = p * inv(q) % MOD;
  vector<ll> pr(N);
  REP(i, N) {
    ll t = 2 * ((MOD - r) % MOD) + 1 % MOD;
    ll p0 = i <= M ? 1 : 0;
    pr[i] = (modpow(t, K, MOD) * (p0 + ((MOD - inv(2)) % MOD)) % MOD) % MOD +
            inv(2) % MOD;
  }
  ll ans = 0;
  REP(i, N) { (ans += b[i] * pr[i] % MOD) %= MOD; }
  cout << ans << endl;
}
0