結果

問題 No.897 compαctree
ユーザー joybeeeejoybeeee
提出日時 2020-05-15 21:35:31
言語 Java19
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 83,508 KB
実行使用メモリ 57,748 KB
最終ジャッジ日時 2023-10-19 12:48:00
合計ジャッジ時間 4,867 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
57,516 KB
testcase_01 AC 134 ms
57,464 KB
testcase_02 AC 127 ms
57,484 KB
testcase_03 AC 127 ms
57,472 KB
testcase_04 AC 128 ms
57,436 KB
testcase_05 AC 127 ms
57,748 KB
testcase_06 AC 133 ms
57,472 KB
testcase_07 AC 130 ms
57,500 KB
testcase_08 AC 127 ms
57,476 KB
testcase_09 AC 119 ms
56,952 KB
testcase_10 AC 129 ms
57,168 KB
testcase_11 AC 126 ms
57,508 KB
testcase_12 AC 128 ms
57,556 KB
testcase_13 AC 127 ms
57,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int q = sc.nextInt();
      while(q-- > 0) {
        int n = sc.nextInt();
        long k = sc.nextInt();
        if(k == 1) {
          System.out.println(n - 1);
          continue;
        }
        int d = 0;
        while(n > 0) {
          n -= Math.pow(k, d);
          if(n <= 0) break;
          d++;
        }
        System.out.println(d);
      }
  }
}
0