#include <bitset> #include <iostream> #include <map> using namespace std; #define MAX (1LL<<33) class Table { public: Table() { small = new bitset<MAX>; } bool get(long long v) { if (v<MAX) { return small->test(v); } else { return big.count(v)>0; } } void set(long long v) { if (v<MAX) { small->set(v); } else { big[v] = true; } } ~Table() { delete small; small = 0; } private: bitset<MAX> *small; map<long long, bool> big; }; #define WANTED 10000 long long a[1+WANTED]; int main() { Table add; Table mul; long long n = 0; for (long long v=0; v<1000000000LL; v++) { bool ok = true; if (add.get(v+v) || mul.get(v*v)) { ok = false; } if (ok) { map<long long, bool> xadd; for (long long m=1; m<=n; m++) { long long s = a[m]+v; if (xadd.count(s) || add.get(s)) { ok = false; break; } else { xadd[s] = true; } } } if (ok) { map<long long, bool> xmul; for (long long m=2; m<=n; m++) { long long p = a[m]*v; if (xmul.count(p) || mul.get(p)) { ok = false; break; } else { xmul[p] = true; } } } if (ok) { n++; a[n] = v; cout << n << " " << v << endl; if (n==WANTED) { break; } for (long long m=1; m<=n; m++) { add.set(a[m]+a[n]); } for (long long m=2; m<=n; m++) { mul.set(a[m]*a[n]); } } } return 0; }