(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)