QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#586936#5471. Interactive Number Guessingsea_birdWA 0ms3604kbC++201.1kb2024-09-24 16:37:182024-09-24 16:37:18

Judging History

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

  • [2024-09-24 16:37:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-09-24 16:37:18]
  • 提交

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