結果

問題 No.995 タピオカオイシクナーレ
ユーザー utouto97utouto97
提出日時 2020-02-21 22:33:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,893 bytes
コンパイル時間 1,742 ms
コンパイル使用メモリ 166,488 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:10:00
合計ジャッジ時間 3,100 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_04 AC 2 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 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
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*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;
}
0