Link
Walk the Line Problem»
(defun factorial (n)
(cond ((> n 1) (* n (factorial (- n 1))))
(t 1)))
(defun combination (n k) (/ (factorial n) (* (factorial k) (factorial (- n k)))))
(do ((n (read *standard-input* nil) (read *standard-input* nil))
(d (read *standard-input* nil) (read *standard-input* nil))) ((null n))
(let ((r -1) (k (abs d)) (p (/ (+ (abs d) n) 2)))
(cond ((= n k) (setq r 1))
((not (= (mod n 2) (mod k 2))) (setq r 0))
(t (setq r (combination n p))))
(format t "~A ~A-step walks end at ~A~%" r n d)))
-
dewayne63dop liked this
-
techniques22hk liked this
-
really256gp liked this
-
fuckyeahterminals posted this