module main; // https://bokuso.blogspot.com/2014/09/blog-post.html より // インタラクティブ問題、数取りゲーム import std; void main() { // 入力 int N, K; readln.chomp.formattedRead("%d %d", N, K); // 答えの計算と出力 K++; int A = (N - 1) % K, B; writeln(A); stdout.flush(); while (true) { B = readln.chomp.to!int; if (B >= N) break; int diff = (K + 1 - B % K) % K; A = B + diff; writeln(A); stdout.flush(); } }