#include #include #include #include int main() { int n, k; std::cin >> n >> k; assert(1 <= k and k < n and n <= 200000); if (k == 1) { std::cout << 1 << std::endl; return 0; } int a0 = n - 1, a1 = n + 2 * k; std::vector dp(n + k); // -1: declarer win, 0: declarer lose dp.at(n - 1) = -1; for (int i = n - 2; i >= 0; i--) { int d0 = (a0 - i) / 2, d1 = (a1 - i) / 2, d2 = a1 - k - 1 - i; std::vector w; if (a0 <= i + k) w.push_back(a0 - i); if ((i + a0) % 2 == 0 and d0 <= k and dp.at(i + d0) == d0) w.push_back(d0); if ((i + a1) % 2 == 0 and d1 <= k and dp.at(i + d1) == d1) w.push_back(d1); if (a1 - a0 >= k + 2 and dp.at(i + d2) == d2) w.push_back(d2); std::sort(w.begin(), w.end()); decltype(w)::iterator r = std::unique(w.begin(), w.end()); w.erase(r, w.end()); if (i == 0) { if (w.size() == 0) { std::cout << 0 << std::endl; } else { for (int x : w) { std::cout << x << std::endl; } } } else if (w.size() == 0) { dp.at(i) = -1; a1 = a0; a0 = i; } else if (w.size() == 1) { dp.at(i) = w.at(0); } } }