QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#586936 | #5471. Interactive Number Guessing | sea_bird | WA | 0ms | 3604kb | C++20 | 1.1kb | 2024-09-24 16:37:18 | 2024-09-24 16:37:18 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
ll query(ll x) {
std::cout << "query " << x << "\n";
fflush(stdout);
ll a;
std::cin >> a;
return a;
}
ll digit(ll x) {
ll ans = 0LL;
while (x) {
ans += x % 10LL;
x /= 10LL;
}
return ans;
}
ll f[100];
ll c[100];
int main() {
ll beg = query(0);
ll res = 0LL;
f[0] = 1LL;
for (int i = 1; i <= 18; i++)
f[i] = f[i - 1] * 10LL;
for (int i = 1; i >= 0; i--) {
res *= 10LL;
int lf = 1, rf = 9;
int ans = -1;
while (lf <= rf) {
int mid = (lf + rf) >> 1;
int tmp = query(mid * f[i]) - beg;
if (tmp == mid) {
lf = mid + 1;
}
else {
ans = mid;
rf = mid - 1;
}
}
if (ans == -1)
ans = 0;
if(ans)
ans = 10 - ans;
res += ans;
}
std::cout << "answer " << res << "\n";
fflush(stdout);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3604kb
input:
6 11 13 5 11 4 12
output:
query 0 query 50 query 70 query 80 query 5 query 7 query 6 answer 23
result:
wrong answer wrong guess: 23 actual: 123