SPJ:
#include "testlib.h"
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char** argv){
registerTestlibCmd(argc,argv);
int n=inf.readInt(1,1000000);
int m=ans.readInt(1,n);
cout<<n<<'\n';
cout.flush();
int cnt=20;
while(cnt>0){
int s=ouf.readInt(1,2),x=ouf.readInt(1,n);
if(s==1){
cnt--;
if(x<=m) cout<<0<<'\n';
else cout<<1<<'\n';
cout.flush();
}
else{
if(x==m) quitf(_ok,"You get the answer with %d questions",20-cnt);
if(x<m) quitf(_wa,"Si is equal to Si+1");
quitf(_wa,"Si+1 is not found");
}
}
quitf(_wa,"You can't get the answer with 20 questions");
}
代码:
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
cin>>n;
int l=1,r=n;
while(l+1<r){
int mid=l+r>>1,x;
cout<<"1 "<<mid<<'\n';
fflush(stdout);
cin>>x;
if(x==0) l=mid;
else r=mid;
}
cout<<"2 "<<l;
fflush(stdout);
}
怎么会
output format Unexpected end of file - int32 expected
呢?格式没有问题啊