結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー |
|
提出日時 | 2020-03-10 04:00:56 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 560 bytes |
コンパイル時間 | 2,111 ms |
コンパイル使用メモリ | 74,620 KB |
実行使用メモリ | 68,308 KB |
最終ジャッジ日時 | 2024-11-07 03:45:39 |
合計ジャッジ時間 | 8,481 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 9 |
ソースコード
import java.util.ArrayList; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } long solve(long A,long B,long C) { long ans=0; while(A>0) { if(C<=A&&A<=2*C-2) { A=0; ans+=B; }else if(A%C!=0) { A-=A%C; }else { A/=C; } ans+=B; } return ans; } void run() { Scanner sc=new Scanner(System.in); int Q=sc.nextInt(); for(int q=0;q<Q;++q) { long A=sc.nextLong(); long B=sc.nextLong(); long C=sc.nextLong(); System.out.println(solve(A,B,C)); } } }