結果

問題 No.995 タピオカオイシクナーレ
ユーザー erbowlerbowl
提出日時 2020-03-28 20:15:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,498 bytes
コンパイル時間 1,663 ms
コンパイル使用メモリ 167,080 KB
実行使用メモリ 15,720 KB
最終ジャッジ日時 2023-08-30 18:09:20
合計ジャッジ時間 3,047 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
15,396 KB
testcase_01 AC 13 ms
15,372 KB
testcase_02 AC 13 ms
15,344 KB
testcase_03 AC 12 ms
15,296 KB
testcase_04 AC 13 ms
15,248 KB
testcase_05 AC 13 ms
15,388 KB
testcase_06 AC 13 ms
15,388 KB
testcase_07 AC 13 ms
15,284 KB
testcase_08 AC 12 ms
15,476 KB
testcase_09 AC 13 ms
15,256 KB
testcase_10 AC 13 ms
15,328 KB
testcase_11 AC 13 ms
15,344 KB
testcase_12 AC 13 ms
15,264 KB
testcase_13 AC 13 ms
15,328 KB
testcase_14 AC 12 ms
15,344 KB
testcase_15 AC 13 ms
15,428 KB
testcase_16 AC 26 ms
15,720 KB
testcase_17 AC 26 ms
15,604 KB
testcase_18 AC 25 ms
15,652 KB
testcase_19 AC 25 ms
15,672 KB
testcase_20 AC 25 ms
15,712 KB
testcase_21 AC 25 ms
15,700 KB
testcase_22 AC 25 ms
15,660 KB
testcase_23 AC 25 ms
15,708 KB
testcase_24 AC 25 ms
15,700 KB
testcase_25 AC 25 ms
15,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

const int MAX = 510000;
 const int MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 
  long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }

int main() {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    COMinit();
    ll n,m,k,p,q;
    std::cin >> n>>m>>k>>p>>q;
    ll e,o;
    e = o = 0;
    
    e = modpow(2,MOD-2)*(modpow(1-2*p%MOD*modpow(q,MOD-2)%MOD+MOD,k)+1);
    e %= MOD;
    o = 1-e+MOD;
    o %= MOD;
    
    // std::cout << e<< " "<<o << std::endl;

    ll ans = 0;
    vector<ll> b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
        if(i<m){
            ans += e*b[i];
            ans %= MOD;
        }else{
            ans += o*b[i];
            ans %= MOD;
        }
    }
    
    std::cout << ans << std::endl;
}

0