結果

問題 No.53 悪の漸化式
ユーザー neko_the_shadowneko_the_shadow
提出日時 2017-01-14 21:18:38
言語 Scheme
(Gauche-0.9.14)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 14,048 KB
最終ジャッジ日時 2023-08-23 10:46:27
合計ジャッジ時間 1,539 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
11,928 KB
testcase_01 AC 20 ms
12,000 KB
testcase_02 AC 20 ms
11,812 KB
testcase_03 AC 20 ms
11,992 KB
testcase_04 AC 20 ms
11,940 KB
testcase_05 AC 20 ms
12,056 KB
testcase_06 AC 20 ms
12,000 KB
testcase_07 AC 20 ms
11,876 KB
testcase_08 AC 20 ms
11,872 KB
testcase_09 AC 20 ms
11,760 KB
testcase_10 AC 19 ms
11,756 KB
testcase_11 AC 19 ms
11,832 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

(define *memo* (make-hash-table))


(define (A k)
  (if (hash-table-exists? *memo* k)
    (hash-table-get *memo* k)
    (let ((val (cond ((= k 0) 4)
                     ((= k 1) 3)
                     (else (/ (- (* 19 (A (- k 1)))
                                 (* 12 (A (- k 2))))
                               4)))))
        (hash-table-put! *memo* k val)
        val)))


(let* ((k (read))
       (float (number->string (exact->inexact (A k))))
       (index (string-scan float #\e))
       (answer (if index (substring float 0 index) float)))
    (display answer)
    (newline))
0