(define (f n) (let ((grundy (make-vector 101 0))) (vector-set! grundy 2 1) (do ((i 3 (+ i 1))) ((> i n)) (let* ((a (bitwise-xor (vector-ref grundy (quotient i 3)) (vector-ref grundy (+ (quotient i 3) (if (> (remainder i 3) 0) 1 0))) (vector-ref grundy (+ (quotient i 3) (if (> (remainder i 3) 1) 1 0)))))) ((b (bitwise-xor (vector-ref grundy (quotient i 2)) (vector-ref grundy (+ (quotient i 2) (if (= (remainder i 2) 1) 1 0)))))) (let loop () (when (or (= (vector-ref grundy i) a) (= (vector-ref grundy i) b)) (vector-set! grundy i (+ 1 (vector-ref grundy i))) (loop))))) grundy)) (define yuki153 (let* ((n (read)) (grundy (f n))) (if (= n 1) (display "B\n") (if (zero? (vector-ref grundy n)) (display "B\n") (display "A\n")))))