結果

問題 No.897 compαctree
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2019-11-06 16:51:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 264 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 11,500 KB
実行使用メモリ 15,444 KB
最終ジャッジ日時 2023-10-13 02:37:35
合計ジャッジ時間 2,795 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,400 KB
testcase_01 AC 81 ms
15,204 KB
testcase_02 AC 83 ms
15,328 KB
testcase_03 AC 81 ms
15,304 KB
testcase_04 AC 81 ms
15,236 KB
testcase_05 AC 81 ms
15,136 KB
testcase_06 AC 80 ms
15,272 KB
testcase_07 AC 82 ms
15,304 KB
testcase_08 AC 80 ms
15,400 KB
testcase_09 AC 81 ms
15,444 KB
testcase_10 AC 80 ms
15,236 KB
testcase_11 AC 82 ms
15,100 KB
testcase_12 AC 80 ms
15,300 KB
testcase_13 AC 82 ms
15,008 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

include Math

def depth(n,k)
  return n - 1 if k == 1
  # (k^{d+1} - 1)/(k-1) >= n
  # d >= log(n * (k-1) + 1) / log(k) - 1
  (log(n*(k-1) + 1) / log(k) - 1).ceil
end

Q = gets.to_i
puts Q.times.map{ gets.split.map(&:to_i) }
       .map{|n,k| depth(n, k) }
       
0