結果

問題 No.897 compαctree
ユーザー Beat7501Beat7501
提出日時 2019-10-25 19:36:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 71,948 KB
実行使用メモリ 55,968 KB
最終ジャッジ日時 2023-09-28 21:59:57
合計ジャッジ時間 5,251 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,596 KB
testcase_01 AC 133 ms
55,680 KB
testcase_02 AC 132 ms
55,760 KB
testcase_03 AC 133 ms
55,896 KB
testcase_04 AC 133 ms
55,672 KB
testcase_05 AC 133 ms
55,668 KB
testcase_06 AC 132 ms
55,396 KB
testcase_07 AC 131 ms
55,860 KB
testcase_08 AC 131 ms
55,968 KB
testcase_09 AC 128 ms
55,700 KB
testcase_10 AC 131 ms
55,712 KB
testcase_11 AC 132 ms
55,456 KB
testcase_12 AC 133 ms
55,624 KB
testcase_13 AC 131 ms
55,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main3{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		long[] n = new long[q];
		long[] k = new long[q];
		for(int i = 0; i < q; i++){
			n[i] = sc.nextLong();
			k[i] = sc.nextLong();
		}
		for(int i = 0; i < q; i++){
			if(k[i] == 1){
				System.out.println(n[i]-1);
			}else{
				int cou = 1;
				long tmp = k[i];
				while(tmp < n[i]){
					tmp*=k[i];
					cou++;
				}
				System.out.println(cou);
			}
		}
	}
}
0