結果
| 問題 |
No.897 compαctree
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-08-28 05:26:07 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 664 bytes |
| コンパイル時間 | 2,532 ms |
| コンパイル使用メモリ | 74,336 KB |
| 実行使用メモリ | 41,452 KB |
| 最終ジャッジ日時 | 2024-11-09 01:00:35 |
| 合計ジャッジ時間 | 4,950 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
import java.util.*;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int q = sc.nextInt();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < q; i++) {
int n = sc.nextInt();
long k = sc.nextInt();
int count = 0;
long sum = 0;
long base = 1;
if (k == 1) {
count = n;
} else {
while (sum < n) {
count++;
sum += base;
base *= k;
}
}
sb.append(count - 1).append("\n");
}
System.out.print(sb);
}
}
tenten