結果

問題 No.897 compαctree
ユーザー Beat7501
提出日時 2019-10-25 19:36:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 2,312 ms
コンパイル使用メモリ 78,268 KB
実行使用メモリ 41,456 KB
最終ジャッジ日時 2024-07-21 16:45:24
合計ジャッジ時間 5,252 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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