結果

問題 No.995 タピオカオイシクナーレ
ユーザー utouto97utouto97
提出日時 2020-02-21 23:17:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,553 bytes
コンパイル時間 1,822 ms
コンパイル使用メモリ 165,868 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 09:18:40
合計ジャッジ時間 2,921 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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 % mod * y % mod;
  }

  V<int> cnt(2);
  cnt[0] = 1;
  cnt[1] = 0;
  int i = 0;
  while (k) {
    if (k % 2) {
      int t = cnt[0];
      int s = cnt[1];

      int x = e[i][0];
      int y = e[i][1];

      cnt[0] = (t * x % mod + s * y % mod) % mod;
      cnt[1] = (t * y % mod + s * x % mod) % mod;
    }

    k /= 2;
    i++;
  }

  V<int> sum(2);
  rep(i, 0, m)(sum[0] += b[i]) %= mod;
  rep(i, m, n)(sum[1] += b[i]) %= mod;

  int ans = 0;
  (ans += sum[0] * cnt[0] % mod) %= mod;
  (ans += sum[1] * cnt[1] % mod) %= mod;
  cout << ans << endl;

  return 0;
}
0