結果

問題 No.3462 Buttons
コンテスト
ユーザー karinohito
提出日時 2026-02-28 14:45:36
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 773 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,568 ms
コンパイル使用メモリ 337,792 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-28 14:45:55
合計ジャッジ時間 7,364 ms
ジャッジサーバーID
(参考情報)
judge1 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 10 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#include<atcoder/modint>
using namespace atcoder;
using mint=modint998244353;

mint solve(ll A,ll B,ll K){
    ll an=0;
    if((B>=0&&A<0)||A==0){
        return 0;
    }
    else if(A<0){
        return solve(-A,-B,K-1)*(-B);
    }
    else if(B==0||B==1||B==-1){
        return mint(A)*K;
    }
    else if(B>0){
        return mint(A)*mint(B).pow(K-1);
    }
    else if(K%2==1){
        return mint(A)*mint(B).pow(K-1);
    }
    else{
        return mint(A)*mint(B).pow(K-2)*2;
    }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll T;
    cin>>T;
    while(T--){
        ll A,B,K;
        cin>>A>>B>>K;
        mint an=solve(A,B,K);
        cout<<an.val()<<"\n";
    }
}
0