QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#277454#5471. Interactive Number GuessingMasterTasterCompile Error//C++14810b2023-12-06 19:06:302023-12-06 19:06:32

Judging History

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

  • [2023-12-06 19:06:32]
  • 评测
  • [2023-12-06 19:06:30]
  • 提交

answer

#include <iostream>

#define ll long long

using namespace std;

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

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

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

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

    pitaj(0LL);
    sum=ret;

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

    cout<<"answer "<<
    for (int i=17; i>=0; i--) cout<<cifra[i];
    cout<<endl;
}

Details

answer.code: In function ‘int main()’:
answer.code:47:5: error: expected primary-expression before ‘for’
   47 |     for (int i=17; i>=0; i--) cout<<cifra[i];
      |     ^~~
answer.code:47:20: error: ‘i’ was not declared in this scope
   47 |     for (int i=17; i>=0; i--) cout<<cifra[i];
      |                    ^