QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#277516#5471. Interactive Number GuessingMasterTasterCompile Error//C++14973b2023-12-06 19:37:272023-12-06 19:37:29

Judging History

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

  • [2023-12-06 19:37:29]
  • 评测
  • [2023-12-06 19:37:27]
  • 提交

answer

#include <iostream>

#define ll long long

using namespace std;

ll sum, ret, na[20], cifra[20], cnt;

void pitaj(ll a)
{
    cout<<"query "<<a<<endl;
    cin>>ret;
}

bool check(ll c, ll k)
{
    pitaj(c*(na[k]));
    cnt++;
    if (cnt==75) assert(0);
    return (ret==(sum+c));
}

int main() {
    na[0]=1;
    for(int i=1; i<18; i++) na[i]=10LL*na[i-1];

    pitaj(0LL);
    cnt++;
    sum=ret;

    for (ll i=17; i>=0; i--)
    {
        ll l=0, r=9;
        int ress=10;
        while (l<=r)
        {
            ll mid=l+(r-l)/2;
            if (!check(mid, i))
            {
                ress=mid;
                r=mid-1;
            }
            else
                l=mid+1;
        }
        cifra[i]=10-ress;
    }

    cout<<"answer ";
    int i;
    for (i=17; i>=0; i--) if (cifra[i]!=0) break;
    if (i==0) { cout<<0<<endl; exit(0); }
    while (i>=0) { cout<<cifra[i]; i--; }
    cout<<endl;
}

Details

answer.code: In function ‘bool check(long long int, long long int)’:
answer.code:19:18: error: ‘assert’ was not declared in this scope
   19 |     if (cnt==75) assert(0);
      |                  ^~~~~~
answer.code:2:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’?
    1 | #include <iostream>
  +++ |+#include <cassert>
    2 |