萌新不会交互题,求大佬指点
  • 板块学术版
  • 楼主Code_quantum
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/1/26 00:37
  • 上次更新2023/10/24 03:04:35
查看原帖
萌新不会交互题,求大佬指点
933880
Code_quantum楼主2023/1/26 00:37

这是 CF D 的代码,不知道该怎么判有没有读入

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
#define N 200005
typedef long long ll;
typedef double db;
int t,a[3];
void work(){
	scanf("%d",&a[1]); int ans=0;
	int now=pow(2,0); bool flag=1;
	for(int j=0;j>=0;j--){
		printf("- %d\n",now);
		fflush(stdout); flag^=1;
		scanf("%d",&a[flag]);
		if(a[flag]==a[flag^1]-1) ans|=now;
		now/=2;
	}
	printf("! %d\n",ans);
	fflush(stdout);
}
int main(){
	scanf("%d",&t);
	while(t--) work();
	return 0;
}
2023/1/26 00:37
加载中...