#include #include #include #include using namespace std; #define MAX (1LL<<33) long long total = 0; // sum of first n terms bitset *aa = 0; // marks sums of distinct terms void mark(long long v) { for (long long n=(total+v)=0; n--) { if (aa->test(n)) { aa->set(n+v); } } } long long other(long long v, int r) { for (long long w=v+1; wtest(w)) { r--; if (r==0) { return w; } } } cerr << "# the end" << endl; exit(0); } int main() { aa = new bitset; aa->set(0); // empty sum long long v = 0; for (int n=1;; n++) { v = other(v, n); cout << n << ' ' << v << endl; total += v; mark(v); } return 0; }