結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー | Common Lisp |
提出日時 | 2024-10-30 12:55:34 |
言語 | Common Lisp (sbcl 2.3.8) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 505 bytes |
コンパイル時間 | 529 ms |
コンパイル使用メモリ | 35,264 KB |
実行使用メモリ | 29,860 KB |
最終ジャッジ日時 | 2024-10-30 12:55:36 |
合計ジャッジ時間 | 1,677 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
25,768 KB |
testcase_01 | AC | 10 ms
27,984 KB |
testcase_02 | AC | 10 ms
27,940 KB |
testcase_03 | AC | 10 ms
25,896 KB |
testcase_04 | AC | 10 ms
29,860 KB |
testcase_05 | AC | 9 ms
25,896 KB |
testcase_06 | AC | 9 ms
25,896 KB |
testcase_07 | AC | 9 ms
25,892 KB |
testcase_08 | AC | 10 ms
27,980 KB |
testcase_09 | AC | 10 ms
25,896 KB |
testcase_10 | AC | 10 ms
25,896 KB |
testcase_11 | AC | 9 ms
25,896 KB |
testcase_12 | AC | 9 ms
25,900 KB |
testcase_13 | AC | 9 ms
27,976 KB |
testcase_14 | AC | 9 ms
25,896 KB |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 30 OCT 2024 12:55:34 PM): ; file: /home/judge/data/code/Main.lisp ; in: DEFUN FIB ; (ZEROP C) ; ; note: unable to ; open-code FLOAT to RATIONAL comparison ; due to type uncertainty: ; The first argument is a NUMBER, not a SINGLE-FLOAT. ; ; note: unable to ; open-code FLOAT to RATIONAL comparison ; due to type uncertainty: ; The first argument is a NUMBER, not a DOUBLE-FLOAT. ; ; note: unable to ; open-code FLOAT to RATIONAL comparison ; due to type uncertainty: ; The first argument is a NUMBER, not a (COMPLEX SINGLE-FLOAT). ; ; note: unable to ; open-code FLOAT to RATIONAL comparison ; due to type uncertainty: ; The first argument is a NUMBER, not a (COMPLEX DOUBLE-FLOAT). ; ; note: unable to open code because: The operands might not be the same type. ; (MOD B M) ; ; note: unable to ; optimize ; due to type uncertainty: ; The first argument is a REAL, not a SINGLE-FLOAT. ; The second argument is a REAL, not a (OR SINGLE-FLOAT INTEGER). ; ; note: unable to ; optimize ; due to type uncertainty: ; The first argument is a REAL, not a DOUBLE-FLOAT. ; The second argument is a REAL, not a (OR FLOAT INTEGER). ; ; note: unable to ; optimize ; due to type uncertainty: ; The first argument is a REAL, not a INTEGER. ; The second argument is a REAL, not a INTEGER. ; (MOD (+ (* P P) (* Q Q)) M) ; ; note: unable to ; optimize ; due to type uncertainty: ; The first argument is a REAL, not a SINGLE-FLOAT. ; The second argument is a REAL, not a (OR SINGLE-FLOAT INTEGER). ; ; note: unable to ; optimize ; due to type uncertainty: ; The first argument is a REAL, not a DOUBLE-FLOAT. ; The second argument is a REAL, not a (OR FLOAT INTEGER). ; ; note: unable to ; optimize ; due to type uncertainty: ; The first argument is a REAL, not a INTEGER. ; The second argument is a REAL, not a INTEGER. ; (* 2 P Q) ; ; note: unable to ; optimize ; due to ty
ソースコード
(declaim (optimize (speed 3) (safety 0))) (defun fib (n m) (labels ((rec (a b c p q) (cond ((zerop c) (mod b m)) ((evenp c) (rec a b (floor c 2) (mod (+ (* p p) (* q q)) m) (mod (+ (* 2 p q) (* q q)) m))) (t (rec (mod (+ (* b q) (* a q) (* a p)) m) (mod (+ (* b p) (* a q)) m) (1- c) p q))))) (rec 1 0 n 0 1))) (defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (m (read))) (format t "~D~%" (fib (1- n) m)))) (main)