結果

問題 No.897 compαctree
ユーザー ducktail
提出日時 2019-10-08 13:09:35
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-11-06 22:13:21
合計ジャッジ時間 1,512 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (read-list q)
  (cond [(zero? q) '()]
        [else (let* ([n (read)]
                     [k (read)])
                (cons (list n k) (read-list (- q 1))))]))

(define (solve nk)
  (let ([n (car nk)]
        [k (cadr nk)])
    (cond [(= k 1) (- n 1)]
          [else (- (inexact->exact (ceiling (log (+ 1 (* n (- k 1))) k))) 1)])))

(define (main args)
  (let* ([q (read)]
         [lnk (read-list q)])
    (for-each print (map solve lnk)))
  0)
0