QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#151472#5556. Diabolic Doofenshmirtzvalue0WA 2ms3516kbC++20598b2023-08-26 18:59:522023-08-26 18:59:53

Judging History

你现在查看的是最新测评结果

  • [2023-08-26 18:59:53]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3516kb
  • [2023-08-26 18:59:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll n, k;

ll query(ll x)
{
	cout<<"? "<<x<<endl;
	std::cout << std::flush;
	ll res;
	cin>>res;
	return res;
}

void solve()
{
	ll l = 0;
	ll r = 1e12 + 1;
	while(l + 1 < r)
	{
		ll mid = l + r >> 1;
		ll t = query(mid);
		if(t == mid)
		{
			cout<<"! "<<t<<endl;
			std::cout << std::flush;
			break;
		}
		else if(t > mid)
		{
			l = mid;
		}
		else
		{
			r = mid;
		}
	}
}

int main()
{
    int t = 1;
    //	cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3516kb

input:

32

output:

? 500000000000
? 250000000000

result:

wrong answer Integer 250000000000 violates the range [500000000001, 1000000000000000001]