結果
| 問題 |
No.915 Plus Or Multiple Operation
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-06-10 17:52:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 784 bytes |
| コンパイル時間 | 2,201 ms |
| コンパイル使用メモリ | 75,152 KB |
| 実行使用メモリ | 54,624 KB |
| 最終ジャッジ日時 | 2024-11-07 03:47:38 |
| 合計ジャッジ時間 | 4,756 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | WA * 10 |
ソースコード
import java.util.*;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
int a = sc.nextInt();
long b = sc.nextInt();
int c = sc.nextInt();
if (c == 1) {
sb.append(-1).append("\n");
} else {
sb.append(getCount(a, c) * b).append("\n");
}
}
System.out.print(sb);
}
static int getCount(int x, int y) {
if (x == 0) {
return 0;
} else if (x % y == 0) {
return getCount(x / y, y) + 1;
} else if ((y - 1) * 2 >= x) {
return 2;
} else {
return getCount(x - x % y, y) + 1;
}
}
}
htensai