(use scheme.bitwise) (define (calculate n k) (if (< n k) -1 (let loop-n ((x 0) (ans 0)) (if (= x 123456) ans (loop-n (+ x 1) (+ ans (let loop-k ((current-k 0) (count 0)) (if (> current-k k) count (let ((y (+ x current-k))) (if (= (bitwise-and x y) n) (loop-k (+ current-k 1) (+ count 1)) (loop-k (+ current-k 1) count))))))))))) (define yuki812 (let* ( (n (read)) (k (read)) (a (calculate n k)) ) (if (= a -1) (display "INF\n") (print a) ) ) )