#include <iostream> #include <unordered_set> #include <vector> #include <cmath> int main() { std::vector<int> a(1000001); std::vector<int> forbidden(1, -1); std::unordered_set<int> seen; for (int n = 0; n<a.size(); n++) { if (n) { // 0...0...0 forbidden[0] = n; } // mark other forbidden values for (int m = n-2; m > -n; m-=2) { int f = 2 * a[abs((m+n)/2)] - a[abs(m)]; if (f >= 0) { while (f >= forbidden.size()) { forbidden.resize(2 * forbidden.size(), -1); } forbidden[f] = n; } } while (a[n] < forbidden.size() && forbidden[a[n]]==n) { a[n]++; } if (!seen.count(a[n])) { std::cout << seen.size() << ' ' << a[n] << std::endl; seen.insert(a[n]); } } return 0; }