#include using namespace std; int CalcDeclarationNum(int prevDeclarationNum, int returnNum, int K) { return returnNum + K - (returnNum - prevDeclarationNum - 1); } int main() { int N, K; cin >> N >> K; int firstAddNum = (N - 1) % (K + 1); bool isPreceding; if (firstAddNum == 0) { isPreceding = false; cout << 0 << endl; } else { isPreceding = true; } int declarationNum = 0; int returnNum = 0; if (isPreceding) { while (true) { if (returnNum == 0) { declarationNum = firstAddNum; } else { declarationNum = CalcDeclarationNum(declarationNum, returnNum, K); } cout << declarationNum << endl; cin >> returnNum; if (returnNum >= N) break; } } else { while (true) { cin >> returnNum; if (returnNum >= N) break; declarationNum = CalcDeclarationNum(declarationNum, returnNum, K); cout << declarationNum << endl; } } return 0; }