QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#224123#5471. Interactive Number GuessingDAleksaWA 1ms3600kbC++14851b2023-10-23 00:00:342023-10-23 00:00:34

Judging History

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

  • [2023-10-23 00:00:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2023-10-23 00:00:34]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

long long n;

int d(long long n) {
    int res = 0;
    while(n > 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

int ask(long long x) {
//    return d(n + x);
    cout << "query " << x << endl;
    long long res;
    cin >> res;
    return res;
}

int main() {
//    cin >> n;
    int sum = ask(0);
    long long res = 0;
    long long pw = 1;
    for(int i = 0; i < 18; i++) {
        int l = 1, r = 10;
        int ans = r;
        while(l <= r) {
            int mid = (l + r) / 2;
            if(ask(mid * 1LL * pw) != sum + mid) {
                ans = mid;
                r = mid - 1;
            } else l = mid + 1;
        }
        res += pw * (10 - ans);
        pw *= 10;
    }
    cout << "answer " << res;
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3600kb

input:

6
11
5
12
4
11
5
12
13
11
14
6
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15
7
11
14
15

output:

query 0
query 5
query 8
query 6
query 7
query 50
query 80
query 60
query 70
query 500
query 800
query 900
query 5000
query 8000
query 9000
query 10000
query 50000
query 80000
query 90000
query 100000
query 500000
query 800000
query 900000
query 1000000
query 5000000
query 8000000
query 9000000
query...

result:

wrong answer invalid range in query_count=71: 1000000000000000000