結果

問題 No.995 タピオカオイシクナーレ
ユーザー ngtkanangtkana
提出日時 2020-03-28 00:14:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,277 bytes
コンパイル時間 3,712 ms
コンパイル使用メモリ 204,936 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-30 17:05:19
合計ジャッジ時間 5,763 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,504 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
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 lint=long long;
lint inverse(lint a, lint m){
    lint u=0,v=1;
    while(a!=0){
        lint t=m/a;
        m-=t*a;std::swap(a,m);
        u-=t*v;std::swap(u,v);
    }
    assert(m==1);
    return u;
}
lint mod=1'000'000'007;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m,K,p,q;std::cin>>n>>m>>K>>p>>q;
    p=p*inverse(q,mod)%mod;
    lint A=0,B=0;
    for(lint i=0;i<n;i++){
        lint x;std::cin>>x;
        (i<m?A:B)+=x;
    }
    std::vector<std::vector<lint>>zero(2,std::vector<lint>(2));
    auto a=zero;
    for(lint i=0;i<2;i++)for(lint j=0;j<2;j++){
        a.at(i).at(j)=i==j?(mod+1-p)%mod:p;
    }
    auto mul=[zero](auto&&a,auto&&b){
        auto c=zero;
        for(lint i=0;i<2;i++)for(lint j=0;j<2;j++)for(lint k=0;k<2;k++){
            c.at(i).at(k)+=a.at(i).at(j)*b.at(j).at(k);
        }
        for(lint i=0;i<2;i++)for(lint j=0;j<2;j++)c.at(i).at(j)%=mod;
        return c;
    };
    auto b=zero;
    for(lint i=0;i<2;i++)for(lint j=0;j<2;j++){
        b.at(i).at(j)=i==j;
    }
    for(;K;K/=2){
        if(K%2)b=mul(b,a);
        a=mul(a,a);
    }
    std::cout<<(b.at(0).at(0)*A+b.at(0).at(1)*B)%mod<<'\n';
}
0