結果

問題 No.887 Collatz
ユーザー ducktailducktail
提出日時 2019-09-20 21:44:30
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 5,340 KB
実行使用メモリ 13,908 KB
最終ジャッジ日時 2023-10-12 18:38:53
合計ジャッジ時間 2,689 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
11,848 KB
testcase_01 AC 19 ms
11,848 KB
testcase_02 AC 18 ms
11,756 KB
testcase_03 AC 18 ms
11,900 KB
testcase_04 AC 18 ms
11,672 KB
testcase_05 AC 19 ms
13,788 KB
testcase_06 AC 19 ms
13,700 KB
testcase_07 AC 18 ms
11,724 KB
testcase_08 AC 18 ms
11,724 KB
testcase_09 AC 19 ms
11,680 KB
testcase_10 AC 18 ms
11,648 KB
testcase_11 AC 18 ms
11,680 KB
testcase_12 AC 18 ms
13,796 KB
testcase_13 AC 18 ms
11,684 KB
testcase_14 AC 18 ms
11,796 KB
testcase_15 AC 18 ms
11,648 KB
testcase_16 AC 18 ms
11,672 KB
testcase_17 AC 18 ms
11,784 KB
testcase_18 AC 18 ms
11,672 KB
testcase_19 AC 18 ms
11,892 KB
testcase_20 AC 19 ms
11,752 KB
testcase_21 AC 19 ms
11,716 KB
testcase_22 AC 18 ms
11,760 KB
testcase_23 AC 18 ms
11,856 KB
testcase_24 AC 19 ms
13,908 KB
testcase_25 AC 19 ms
11,752 KB
testcase_26 AC 18 ms
11,672 KB
testcase_27 AC 18 ms
11,800 KB
testcase_28 AC 18 ms
11,660 KB
testcase_29 AC 19 ms
11,672 KB
testcase_30 AC 19 ms
11,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (solve n)
  (let loop ([i 0]
             [n n]
             [mx n])
    (cond [(= n 1) (list i mx)]
          [(even? n) (loop (+ i 1) (quotient n 2) (max mx (quotient n 2)))]
          [else (loop (+ i 1) (+ (* 3 n) 1) (max mx (+ (* 3 n) 1)))])))

(define (main args)
  (let ([n (read)])
    (map print (solve n)))
  0)
0