#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; unsigned xor128(){ static unsigned x=123456789,y=362436069,z=521288629,w=88675123; unsigned t; t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) ); } int main() { vector v = {0, 1, 2, 3}; int xMax = -1; int yMax = -1; for(;;){ vector w = v; if(xMax + yMax == 4){ int i = xor128() % 4; int j; do{ j = xor128() % 4; }while(i == j); swap(w[i], w[j]); } else{ int i = xor128() % 4; int a; do{ a = xor128() % 10; }while(find(v.begin(), v.end(), a) != v.end()); w[i] = a; } cout << w[0]; for(int i=1; i<4; ++i) cout << ' ' << w[i]; cout << endl; int x, y; cin >> x >> y; if(x == 4){ return 0; } if(xMax + yMax < x + y || (xMax + yMax == x + y && xMax < x)){ v = w; xMax = x; yMax = y; } } }