#include #include #include using namespace std; long long Z = 0; long long V = 0; #define MAX 5001 long long a[MAX]; long long u = 1; struct Node { Node(long long k, long long n) : z(++Z), k(k), n(n), v(k==2 ? ++V : -1) { if (this->v>0 && this->nn] = this->v; while (u &children) { for (int c=0; ck; c++) { children.push(new Node(this->z%2 ? 2 : 1, k==1 ? this->n : (2*this->n+c))); } } }; int main() { memset(a, 0, sizeof(a)); queue nodes; nodes.push(new Node(1, 1)); while (uExpand(nodes); delete top; } return 0; }