結果

問題 No.995 タピオカオイシクナーレ
ユーザー hiro71687khiro71687k
提出日時 2023-04-16 18:14:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,259 bytes
コンパイル時間 3,781 ms
コンパイル使用メモリ 255,276 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 06:17:14
合計ジャッジ時間 5,360 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=1444999999;
ll mod=1000000007;
ll modpow(ll x, ll n) {
  x = x%mod;
  if(n==0) return 1;  //再帰の終了条件

  else if(n%2==1) {
    return (x*modpow(x, n-1))%mod;  //nが奇数ならnを1ずらす
  }
  else return modpow((x*x)%mod, n/2)%mod;  //nが偶数ならnが半分になる
}
int main(){
    ll n,m,k,p,q;
    cin >> n >> m >> k >> p >> q;
    vector<ll>c(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    ll a=p;
    ll b=q-p+mod;
    b%=mod;
    ll x=modpow((a+b)%mod,k);
    ll y=modpow((a-b+mod)%mod,k);
    ll ans=0;
    ll qq=modpow(q,k);
    qq=inv_mod(qq,mod);
    for (ll i = 0; i < m; i++)
    {
        ll xx=x+y;
        xx%=mod;
        xx*=qq;
        xx%=mod;
        xx*=inv_mod(2,mod);
        xx%=mod;
        xx*=c[i];
        xx%=mod;
        ans+=xx;
        ans%=mod;
    }
    for (ll i = m; i < n; i++)
    {
        ll xx=x-y+mod;
        xx%=mod;
        xx*=qq;
        xx%=mod;
        xx*=inv_mod(2,mod);
        xx%=mod;
        xx*=c[i];
        xx%=mod;
        ans+=xx;
        ans%=mod;
    }
    cout << ans << endl;
}
0