QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#277454 | #5471. Interactive Number Guessing | MasterTaster | Compile Error | / | / | C++14 | 810b | 2023-12-06 19:06:30 | 2023-12-06 19:06:32 |
Judging History
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;
}
詳細信息
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]; | ^