QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#305846 | #5471. Interactive Number Guessing | basoo0 | TL | 0ms | 0kb | C++20 | 824b | 2024-01-16 04:08:24 | 2024-01-16 04:08:25 |
answer
#include <bits/stdc++.h>
using namespace std;
int main()
{
// ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
cout<<"query 0"; fflush(stdout);
long long x; cin>>x;
long long y=0;
string ans;
for(long long i=1 ; i<18 ; i++){
int l=0,r=9;
while(l<=r){
int mid=(l+r)/2;
cout<<"query "<<mid*pow(10,i-1); fflush(stdout);
long long y; cin>>y;
if(y>x)l=mid+1;
else r=mid-1;
}
ans.push_back(l+'0');
cout<<ans<<" ";
}
reverse(ans.begin(),ans.end());
bool f=0;
for(int i=0 ; i<18 ; i++){
if(ans[i]>='1' && ans[i]<='9')f=1;
if(ans[i]<'0')ans[i]='0';
if(f) cout<<ans[i];
}
// cout<<"answer "<<ans; fflush(stdout);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
output:
query 0