Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	char s[2];
	int now,k=1;
	for(now=1;now<=10;now++,k*=10)
	{
		printf("? %d\n",k);
		flush(stdout);
		scanf("%s",s);
		if(s[0]=='N')break;
	}
	now--;
	if(now==10)
	{
		k=2;
		for(now=1;now<=10;now++,k*=10)
		{
			printf("? %d\n",k);
			flush(stdout);
			scanf("%s",s);
			if(s[0]=='Y')return 0*printf("! %d",k/2);
		}
	}
	else
	{
		int l=k/10+1,r=k-1;
		while(l<=r)
		{
			if(l==r-1)
			{
				printf("? %lld\n",(long long)l*10);
				flush(stdout);
				scanf("%s",s);
				if(s[0]=='Y')return 0*printf("! %d",l);
				else return 0*printf("! %d",r);
			}
			int mid=l+r>>1;
			printf("? %lld\n",(long long)mid*10);
			flush(stdout);
			scanf("%s",s);
			if(s[0]=='Y')r=mid;
			else l=mid+1;
		}
	}
	return 0;
}
//1.控制字典序一定小  1,10,100...， 来确定数字位数或是不是10的次幂
//2.找出位数后，控制数字一定大， 二分ans，给交互库ans*10，比较字典序来确定数字 

Compiler output:
a.cc: In function 'int main()':
a.cc:11:22: error: no matching function for call to 'flush(FILE*&)'
   11 |                 flush(stdout);
      |                 ~~~~~^~~~~~~~
In file included from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)'
  766 |     flush(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~~
/usr/include/c++/14/ostream:766:5: note:   template argument deduction/substitution failed:
a.cc:11:22: note:   mismatched types 'std::basic_ostream<_CharT, _Traits>' and 'FILE*'
   11 |                 flush(stdout);
      |                 ~~~~~^~~~~~~~
a.cc:22:30: error: no matching function for call to 'flush(FILE*&)'
   22 |                         flush(stdout);
      |                         ~~~~~^~~~~~~~
/usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)'
  766 |     flush(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~~
/usr/include/c++/14/ostream:766:5: note:   template argument deduction/substitution failed:
a.cc:22:30: note:   mismatched types 'std::basic_ostream<_CharT, _Traits>' and 'FILE*'
   22 |                         flush(stdout);
      |                         ~~~~~^~~~~~~~
a.cc:35:38: error: no matching function for call to 'flush(FILE*&)'
   35 |                                 flush(stdout);
      |                                 ~~~~~^~~~~~~~
/usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)'
  766 |     flush(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~~
/usr/include/c++/14/ostream:766:5: note:   template argument deduction/substitution failed:
a.cc:35:38: note:   mismatched types 'std::basic_ostream<_CharT, _Traits>' and 'FILE*'
   35 |                                 flush(stdout);
      |                                 ~~~~~^~~~~~~~
a.cc:42:30: error: no matching function for call to 'flush(FILE*&)'
   42 |                         flush(stdout);
      |                         ~~~~~^~~~~~~~
/usr/include/c++/14/ostream:766:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::flush(basic_ostream<_CharT, _Traits>&)'
  766 |     flush(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~~
/usr/include/c++/14/ostream:766:5: note:   template argument deduction/substitution failed:
a.cc:42:30: note:   mismatched types 'std::basic_ostream<_CharT, _Traits>' and 'FILE*'
   42 |                         flush(stdout);
      |                         ~~~~~^~~~~~~~