結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー | 37zigen |
提出日時 | 2020-03-10 04:00:56 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 560 bytes |
コンパイル時間 | 1,959 ms |
コンパイル使用メモリ | 71,392 KB |
実行使用メモリ | 64,300 KB |
最終ジャッジ日時 | 2023-08-07 00:37:13 |
合計ジャッジ時間 | 8,444 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
ソースコード
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)); } } }