結果
| 問題 | 
                            No.915 Plus Or Multiple Operation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             IKyopro
                         | 
                    
| 提出日時 | 2019-10-25 21:51:05 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 401 bytes | 
| コンパイル時間 | 775 ms | 
| コンパイル使用メモリ | 69,728 KB | 
| 最終ジャッジ日時 | 2025-01-08 01:08:39 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 6 WA * 4 | 
ソースコード
#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;
    ll r = a%c,k = a/c;
    ll cnt = (r!=0) + (k!=1);
    return cnt*b+solve(k,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;
    }   
}
            
            
            
        
            
IKyopro