智商题, 感觉不太能推出来, 虽然看看证明过程是对的。
#include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int> #define SZ(x) ((int)x.size()) #define ull unsigned long long using namespace std; const int N = 1e5 + 7; const int inf = 0x3f3f3f3f; const LL INF = 0x3f3f3f3f3f3f3f3f; const int mod = 1000000007; const double eps = 1e-6; const double PI = acos(-1); char s[100]; int getIn() { int n; scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%s", s); return n; } int main() { while(1) { printf("next 0 "); fflush(stdout); getIn(); printf("next 0 1 "); fflush(stdout); if(getIn() == 2) break; } while(1) { printf("next 0 1 2 3 4 5 6 7 8 9 "); fflush(stdout); if(getIn() == 1) break; } printf("done "); fflush(stdout); return 0; } /* */