結果

問題 No.897 compαctree
ユーザー tentententen
提出日時 2020-08-28 05:26:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 3,067 ms
コンパイル使用メモリ 71,028 KB
実行使用メモリ 56,244 KB
最終ジャッジ日時 2023-08-08 17:57:55
合計ジャッジ時間 4,523 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,876 KB
testcase_01 AC 121 ms
55,804 KB
testcase_02 AC 121 ms
56,244 KB
testcase_03 AC 119 ms
56,216 KB
testcase_04 AC 119 ms
56,068 KB
testcase_05 AC 120 ms
55,848 KB
testcase_06 AC 120 ms
55,932 KB
testcase_07 AC 119 ms
55,912 KB
testcase_08 AC 121 ms
55,880 KB
testcase_09 AC 121 ms
55,756 KB
testcase_10 AC 122 ms
55,700 KB
testcase_11 AC 120 ms
55,508 KB
testcase_12 AC 122 ms
55,520 KB
testcase_13 AC 120 ms
55,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
    
}
0