QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#277516 | #5471. Interactive Number Guessing | MasterTaster | Compile Error | / | / | C++14 | 973b | 2023-12-06 19:37:27 | 2023-12-06 19:37:29 |
Judging History
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;
}
详细
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 |