結果

問題 No.658 テトラナッチ数列 Hard
ユーザー Common LispCommon Lisp
提出日時 2024-11-13 14:49:45
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,227 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 28,544 KB
実行使用メモリ 22,016 KB
最終ジャッジ日時 2024-11-13 14:49:47
合計ジャッジ時間 1,791 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 13 NOV 2024 02:49:45 PM):

; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.009

ソースコード

diff #
プレゼンテーションモードにする

(defconstant +mod+ 17)
(defvar *tetranacci-mod17* (make-array 1000000 :element-type 'integer :initial-element 0))
(defvar *tetranacci-mod17-index* 0)
(defun tetranacci-mod17-period ()
(setf (aref *tetranacci-mod17* 0) 1
(aref *tetranacci-mod17* 1) 0
(aref *tetranacci-mod17* 2) 0
(aref *tetranacci-mod17* 3) 0
(aref *tetranacci-mod17* 4) 1
*tetranacci-mod17-index* 5)
(loop for i from 5 below 100000 do
(let* ((a (aref *tetranacci-mod17* (- i 1)))
(b (aref *tetranacci-mod17* (- i 2)))
(c (aref *tetranacci-mod17* (- i 3)))
(d (aref *tetranacci-mod17* (- i 4)))
(e (mod (+ a b c d) +mod+)))
(setf (aref *tetranacci-mod17* i) e)
(if (and (= e 1) (= d 0) (= c 0) (= b 0) (= a 1) (/= i 5))
(progn
(decf *tetranacci-mod17-index* 5)
(return-from tetranacci-mod17-period))
(incf *tetranacci-mod17-index*)))))
(defun main (&rest argv)
(declare (ignorable argv))
(tetranacci-mod17-period)
(let* ((query (read)))
(dotimes (_ query)
(format t "~d~%" (aref *tetranacci-mod17* (mod (read) *tetranacci-mod17-index*))))))
(main)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0