結果

問題 No.887 Collatz
ユーザー MiyamonYMiyamonY
提出日時 2019-10-07 02:01:17
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,019 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 5,504 KB
実行使用メモリ 17,280 KB
最終ジャッジ日時 2024-04-20 05:14:53
合計ジャッジ時間 2,242 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
17,024 KB
testcase_01 AC 30 ms
17,024 KB
testcase_02 AC 30 ms
17,152 KB
testcase_03 AC 22 ms
16,000 KB
testcase_04 AC 28 ms
17,024 KB
testcase_05 AC 29 ms
17,024 KB
testcase_06 AC 29 ms
17,024 KB
testcase_07 AC 31 ms
17,024 KB
testcase_08 AC 30 ms
17,152 KB
testcase_09 AC 30 ms
17,024 KB
testcase_10 AC 31 ms
17,152 KB
testcase_11 AC 30 ms
17,024 KB
testcase_12 AC 31 ms
17,152 KB
testcase_13 AC 29 ms
17,280 KB
testcase_14 AC 29 ms
17,280 KB
testcase_15 AC 30 ms
17,024 KB
testcase_16 AC 31 ms
17,280 KB
testcase_17 AC 29 ms
17,024 KB
testcase_18 AC 28 ms
17,024 KB
testcase_19 AC 29 ms
17,024 KB
testcase_20 AC 29 ms
17,024 KB
testcase_21 AC 30 ms
17,280 KB
testcase_22 AC 29 ms
17,024 KB
testcase_23 AC 30 ms
17,152 KB
testcase_24 AC 29 ms
17,024 KB
testcase_25 AC 30 ms
17,024 KB
testcase_26 AC 29 ms
17,024 KB
testcase_27 AC 29 ms
17,280 KB
testcase_28 AC 29 ms
17,024 KB
testcase_29 AC 29 ms
17,024 KB
testcase_30 AC 29 ms
17,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

;;; File:  main.scm
;; Author: ymiyamoto
;;
;; Created on Mon Oct  7 01:53:59 2019
;;
(define-syntax read-number
  (syntax-rules ()
    ((_ nums)
     (define-values nums
       (apply values (map string->number (string-split (read-line) #\space)))))))

(define-syntax read-numbers
  (syntax-rules ()
    ((_ as)
     (define as (map string->number (string-split (read-line) #\space))))
    ((_ as n)
     (define as (map (lambda (_) (map string->number (string-split (read-line) #\space))) (iota n))))))

(define-syntax prlist
  (syntax-rules ()
    ((_ lis)
     (print (string-join (map number->string lis) " ")))))

(define-syntax 1+ (syntax-rules () ((_ x) (+ x 1))))

(define-syntax 1- (syntax-rules () ((_ x) (- x 1))))

(define MOD 1000000007)

(define (solve)
  (read-number (n))

  (define-values (m i)
    (let loop ((n n)
	       (m n)
	       (i 0))
      (if (= n 1)
	  (values m i)
	  (let1 val (if (even? n) (div n 2) (1+ (* 3 n)))
		(loop val (max m val) (1+ i))))))

  (print i)
  (print m))

(solve)
0