結果

問題 No.887 Collatz
ユーザー keiden
提出日時 2024-09-17 16:18:28
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 295 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 6,820 KB
実行使用メモリ 16,384 KB
最終ジャッジ日時 2024-09-17 16:18:31
合計ジャッジ時間 1,850 ms
ジャッジサーバーID
(参考情報)
judge6 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

(use scheme.list)

(define yuki887
  (let*
    (
      (n (read))
      (collatz (unfold (^x (= 1 x)) identity (^x (if (even? x) (quotient x 2) (+ (* x 3) 1))) n))
    )
    (display (if (= n 1) 0 (length collatz)))
    (newline)
    (display (if (= n 1) 1 (apply max collatz)))
    (newline)))
0