結果

問題 No.535 自然数の収納方法
ユーザー Common Lisp
提出日時 2024-11-13 18:40:06
言語 Common Lisp
(sbcl 2.5.0)
結果
AC  
実行時間 442 ms / 2,000 ms
コード長 1,230 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 49,788 KB
実行使用メモリ 94,620 KB
最終ジャッジ日時 2024-11-13 18:40:12
合計ジャッジ時間 6,200 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 13 NOV 2024 06:40:06 PM):

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

ソースコード

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

(defun main (&rest argv)
(declare (ignorable argv))
(let* ((dp1 (make-array (list 2002 2002) :element-type 'integer :initial-element 0))
(dp2 (make-array (list 2002 2002) :element-type 'integer :initial-element 0))
(n (read))
(res 0))
(loop for i from 1 to n do (setf (aref dp1 0 i) 1))
(loop for i from 1 below n do
(setf (aref dp2 (1- i) 0) 0)
(loop for j from 1 to n do (setf (aref dp2 (1- i) j) (mod (+ (aref dp2 (1- i) (1- j)) (aref dp1 (1- i) j)) 1000000007)))
(loop for j from 1 to n do (setf (aref dp1 i j) (mod (aref dp2 (1- i) (min n (+ j -1 (max 1 (1- i))))) 1000000007))))
(loop for i from 1 to n do (incf res (aref dp1 (1- n) i)))
(dotimes (i 2002) (dotimes (j 2002) (setf (aref dp1 i j) 0)))
(setf (aref dp1 0 1) 1)
(loop for i from 1 below n do
(setf (aref dp2 (1- i) 0) 0)
(loop for j from 1 to n do (setf (aref dp2 (1- i) j) (mod (+ (aref dp2 (1- i) (1- j)) (aref dp1 (1- i) j)) 1000000007)))
(loop for j from 1 to n do (setf (aref dp1 i j) (mod (aref dp2 (1- i) (min n (+ j -1 (max 1 (1- i))))) 1000000007))))
(decf res (aref dp1 (1- n) n))
(format t "~d~%" (mod res 1000000007))))
(main)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0