結果
問題 | No.897 compαctree |
ユーザー |
![]() |
提出日時 | 2019-10-04 21:27:18 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 1,798 ms |
コンパイル使用メモリ | 75,424 KB |
実行使用メモリ | 50,296 KB |
最終ジャッジ日時 | 2024-10-03 07:10:52 |
合計ジャッジ時間 | 2,913 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int q = Integer.parseInt(br.readLine()); for (int i = 0; i < q; i++) { String[] sa = br.readLine().split(" "); long n = Integer.parseInt(sa[0]); long k = Integer.parseInt(sa[1]); if (k == 1) { System.out.println(n - 1); } else { long sum = 0; for (int j = 0; j < 40; j++) { long b = (long) Math.pow(k, j); sum += b; if (sum >= n) { System.out.println(j); break; } } } } br.close(); } }