求助玄关
  • 板块学术版
  • 楼主hwc2011
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/12/12 18:38
  • 上次更新2024/12/12 21:51:17
查看原帖
求助玄关
1313003
hwc2011楼主2024/12/12 18:38

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

呢?格式没有问题啊

2024/12/12 18:38
加载中...