/* * 嘘解法 * y + k への遷移を忘れる */ #include int main() { int n, k; std::cin >> n >> k; if (k==1) { std::cout << 1 << '\n'; return 0; } std::vector> a(n+1); std::vector b = {1}; for (int i = 2; i <= n; i++) { auto&& v = a.at(i); int x = b.back(); auto transite = [&](int j) { int d = i - j; if (d <= k && (a.at(j).empty() || (a.at(j).size() == int{1} && a.at(j).front() == d))) { v.push_back(d); } }; transite(x); transite((i + x) / 2); if (int{1} != b.size()) { int y = b.at(b.size() - 2); transite(y + k + 1); transite((i + y) / 2); } std::sort(v.begin(), v.end()); v.resize(std::unique(v.begin(), v.end()) - v.begin()); if (v.empty()) b.push_back(i); } std::vector ans = a.at(n); if (ans.empty()) { std::cout << 0 << '\n'; } else { for (int x: ans) { std::cout << x << '\n'; } } }