(defun facd (n p a) (cond ((equal n 0) 0) ((not (equal (mod a p) 0)) (facd (- n 1) p (* a (- n 1)))) (t (mod (+ (facd n p (/ a p)) 1) 1000000007)) ) ) (defun factorial (n) (if (= n 1) 1 (mod (* n (factorial (- n 1))) 1000000007) ) ) (defun rui (n p) (if (= n 1) p (mod (* p (rui (- n 1) p)) 1000000007) ) ) (defun solve (n p) (setq f (factorial n)) (mod (* (facd (+ n 1) p 1) (rui f f)) 1000000007) ) (princ (solve (read) (read)))