結果
| 問題 | 
                            No.915 Plus Or Multiple Operation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             vwxyz
                         | 
                    
| 提出日時 | 2024-04-17 16:12:23 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 325 bytes | 
| コンパイル時間 | 331 ms | 
| コンパイル使用メモリ | 82,284 KB | 
| 実行使用メモリ | 66,376 KB | 
| 最終ジャッジ日時 | 2024-10-09 10:19:15 | 
| 合計ジャッジ時間 | 1,567 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 8 RE * 2 | 
ソースコード
Q=int(input())
for q in range(Q):
    A,B,C=map(int,input().split())
    inf=1<<30
    def solve(A):
        retu=(A+C-2)//(C-1)*B
        if A:
            if A%C:
                retu=min(retu,solve(A-A%C)+B)
            else:
                retu=min(retu,solve(A//C)+B)
        return retu
    ans=solve(A)
    print(ans)
            
            
            
        
            
vwxyz