結果
| 問題 | 
                            No.645 Count Permutation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Common Lisp
                         | 
                    
| 提出日時 | 2024-11-11 03:02:13 | 
| 言語 | Common Lisp  (sbcl 2.5.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 240 ms / 2,000 ms | 
| コード長 | 867 bytes | 
| コンパイル時間 | 181 ms | 
| コンパイル使用メモリ | 29,440 KB | 
| 実行使用メモリ | 71,936 KB | 
| 最終ジャッジ日時 | 2024-11-11 03:02:17 | 
| 合計ジャッジ時間 | 4,540 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 34 | 
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 11 NOV 2024 03:02:13 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.017
ソースコード
(defconstant +mod+ 1000000007)
(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read))
         (l (read))
         (r (read))
         (dp (make-array (list 100001 64) :element-type 'integer))
         (m 1)
         (res 0))
    (setf (aref dp 0 0) 1)
    (loop for i from 1 below n do
          (setq m (mod (* m i) +mod+))
          (dotimes (j 64)
            (setf (aref dp i j) (mod (+ (* (aref dp (1- i) j) (1- i))
                                        (if (>= j 1)
                                            (aref dp (1- i) (1- j))
                                            0)) +mod+))))
    (dotimes (i 64)
      (when (and (<= l (ash 1 i)) (<= (ash 1 i) r))
            (setq res (mod (+ res (aref dp (1- n) i)) +mod+))))
    (when (zerop l)
          (setq res (mod (+ res (* m (1- n))) +mod+)))
    (format t "~d~%" res)))
(main)
            
            
            
        
            
Common Lisp