(defun prime (x) (let ((primes (make-array (1+ x) :initial-contents (loop for i from 0 to x collect (if (evenp i) 2 i))))) (setf (aref primes 0) 1) (loop for i from 3 to (+ 2 (isqrt x)) by 2 do (when (= (aref primes i) i) (loop for j from (* 2 i) to x by i do (when (= (aref primes j) j) (setf (aref primes j) i))))) (loop for i from 2 to x when (= (aref primes i) i) collect i))) (defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (primes (prime (1+ n))) (dp (make-array (1+ n) :initial-element 0))) (setf (aref dp 0) 1) (setf (aref dp 1) 1) (loop for i from 2 to n do (block inner (loop for p in primes do (when (> p i) (return-from inner)) (when (zerop (aref dp (- i p))) (setf (aref dp i) 1) (return-from inner))))) (format t "~A~%" (if (zerop (aref dp n)) "Lose" "Win")))) #-swank(main)