(defun main (&rest argv) (declare (ignorable argv)) (let* ((a (read)) (p0 (/ (float (read) 0d0) 100d0)) (p1 (/ (float (read) 0d0) 100d0)) (p2 (/ (float (read) 0d0) 100d0)) (p (make-array 3 :element-type 'double-float :initial-contents (list p0 p1 p2))) (dp (make-array (list (+ 81 (- a)) 15 2) :element-type 'double-float :initial-element 0d0))) (loop for i from 1 to 14 do (dotimes (j 2) (setf (aref dp 0 i j) (float i 0d0)))) (loop for i from 1 to (- 80 a) do (loop for j from 1 to 14 do (dotimes (k 2) (if (= j 1) (setf (aref dp i j k) (* (- 1d0 (aref p k)) (aref dp (1- i) j 0))) (let ((tmp 1d0)) (dotimes (l j) (let ((x (if (or (and (zerop l) (zerop k)) (= j (1+ l))) (aref p 1) (aref p 2)))) (incf (aref dp i j k) (* tmp x (+ (aref dp (1- i) l 0) (aref dp i (- j l 1) 1)))) (setq tmp (* tmp (- 1d0 x))))) (incf (aref dp i j k) (* tmp (aref dp (1- i) j 0)))))))) (format t "~f~%" (* 2 (aref dp (- 80 a) 14 0))))) (main)