結果
問題 |
No.2791 Beginner Contest
|
ユーザー |
|
提出日時 | 2024-06-22 17:09:17 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 638 bytes |
コンパイル時間 | 1,540 ms |
コンパイル使用メモリ | 39,176 KB |
実行使用メモリ | 34,780 KB |
最終ジャッジ日時 | 2024-06-22 17:09:19 |
合計ジャッジ時間 | 1,434 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 22 JUN 2024 05:09:16 PM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.039
ソースコード
(defconstant +mod+ 998244353) (defun solve (n k) (let* ((dp (make-array (1+ n) :initial-element 0)) (sum-dp (make-array (1+ n) :initial-element 0))) (setf (aref dp 0) 1) (setf (aref sum-dp 0) 1) (loop for i from 1 to n do (when (>= i k) (setf (aref dp i) (aref sum-dp (- i k)))) (setf (aref sum-dp i) (mod (+ (aref sum-dp (1- i)) (aref dp i)) +mod+))) (let ((result 0)) (loop for i from 0 to n do (setf result (mod (+ result (aref dp i)) +mod+))) result))) (defun main () (let ((n (read)) (k (read))) (format t "~d~%" (solve n k)))) (main)