結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
コンテスト
ユーザー まんしmaNNshi
提出日時 2025-04-05 11:31:46
言語 Common Lisp
(sbcl 2.6.3)
コンパイル:
sbclc _filename_
実行:
sbcl --script Main.fasl
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 389 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,040 ms
コンパイル使用メモリ 27,392 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2026-07-08 11:50:47
合計ジャッジ時間 2,708 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 08 JUL 2026 11:50:44 AM):

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

ソースコード

diff #
raw source code

(defvar N)
(defvar M)
(defvar temp)
(setq temp (read-from-string (concatenate 'string "(" (read-line) ")")))

(setq N (nth 0 temp))
(setq M (nth 1 temp))
;(format t "~d ~d~%" N M)

(defvar f1)
(defvar f2)
(setq f1 0)
(setq f2 1)
(setq temp 0)
(loop for i from 3 to N do
	(setq temp f2)
	(setq f2 (mod (+ f1 f2) M))
	(setq f1 temp))
(format t "~d~%" (case N (1 0) (2 1) (otherwise f2)))
 	
0