結果

問題 No.915 Plus Or Multiple Operation
ユーザー IKyopro
提出日時 2019-10-25 21:43:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 396 bytes
コンパイル時間 873 ms
コンパイル使用メモリ 69,676 KB
最終ジャッジ日時 2025-01-08 01:06:05
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

ll solve(ll a,ll b,ll c){
    if(c==1) return a*b;
    if(a<c) return b;
    if(a==c) return 2*b;
    return b*(1+((a%c && a/c!=1)? 1:0))+solve(a/c,b,c);
}

int main(){
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        cout << solve(a,b,c) << endl;
    }   
}
0