結果

問題 No.897 compαctree
ユーザー tentententen
提出日時 2020-08-28 05:26:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 75,380 KB
実行使用メモリ 41,624 KB
最終ジャッジ日時 2024-04-26 10:28:27
合計ジャッジ時間 4,648 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,568 KB
testcase_01 AC 135 ms
41,624 KB
testcase_02 AC 143 ms
41,404 KB
testcase_03 AC 149 ms
41,504 KB
testcase_04 AC 132 ms
41,324 KB
testcase_05 AC 134 ms
41,560 KB
testcase_06 AC 131 ms
41,400 KB
testcase_07 AC 132 ms
41,548 KB
testcase_08 AC 129 ms
41,164 KB
testcase_09 AC 129 ms
41,452 KB
testcase_10 AC 119 ms
40,476 KB
testcase_11 AC 123 ms
41,024 KB
testcase_12 AC 125 ms
41,448 KB
testcase_13 AC 113 ms
40,328 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