結果

問題 No.2561 みんな大好きmod 998
ユーザー Common Lisp
提出日時 2024-11-05 22:26:13
言語 Common Lisp
(sbcl 2.5.0)
結果
MLE  
実行時間 -
コード長 639 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 33,396 KB
実行使用メモリ 651,628 KB
最終ジャッジ日時 2024-11-05 22:26:43
合計ジャッジ時間 29,160 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37 MLE * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 05 NOV 2024 10:26:13 PM):

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

ソースコード

diff #

(defun combinations (lst k)
  (if (= k 0)
      (list '())
      (when lst
        (let ((first (car lst))
              (rest (cdr lst)))
          (append (mapcar (lambda (x) (cons first x))
                          (combinations rest (1- k)))
                  (combinations rest k))))))

(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read))
         (k (read))
         (a (loop repeat n collect (read)))
         (res 0))
    (dolist (b (combinations a k))
      (let ((s (reduce #'+ b)))
        (when (<= (mod s 998244353) (mod s 998))
              (incf res))))
    (format t "~d~%" (mod res 998))))

(main)
0