QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#300947#5471. Interactive Number GuessingELDRVDTL 0ms0kbC++141.3kb2024-01-09 02:55:502024-01-09 02:55:50

Judging History

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

  • [2024-01-09 02:55:50]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-01-09 02:55:50]
  • 提交

answer

//https://qoj.ac/contest/1101/problem/5471
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define PI acos(-1)
#define LSB(i) ((i) & -(i))
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define INF 1e18
#define MOD 1000000007
#define endl "\n"

#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
ll dd,mm,mm1,mm2;
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cout<<"query 0"<<endl; cin>>mm;
    if(mm==0) {cout<<"answer 0"<<endl; return 0;}
    for(ll i=1; i<INF;i*=10)
    {
        ll l=1,r=10,mid;
        while(l<r)
        {
            mid=(l+r)/2;
            cout<<"query "<<dd+i*mid<<endl; cin>>mm1;
            if(mm1==mid+mm) l=mid+1;
            else r=mid;
            if(r==mid) mm2=mm1;
        }
        if(l==10) {l=0; cout<<"query "<<dd<<endl; cin>>mm2;}
        dd+=i*l; mm=mm2;
    }
    cout<<"answer "<<INF-dd<<endl;
    return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:


output:


result: