QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#305785#5471. Interactive Number GuessingAliMark71WA 1ms3728kbC++231.5kb2024-01-16 00:01:112024-01-16 00:01:12

Judging History

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

  • [2024-01-16 00:01:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2024-01-16 00:01:11]
  • 提交

answer

//
//  main.cpp
//  GeneralCompetitiveProgramming
//
//  Created by Ali AlSalman on 12/07/2023.
//

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <climits>

#define endl '\n'

using namespace std;

int query(long long n) {
    cout<<"query "<<n<<endl<<flush;
    
    int x;
    cin>>x;
    return x;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    
    
    int initDigitSum = query(0);
    string ans = "";
    for (int digit = 0; digit < 18; digit++) {
        if (query(9 * pow(10, digit)) != initDigitSum) {
            ans += '0';
            continue;
        }
        
        int l = 1, r = 9, binans = -1;
        while (l <= r) {
            int mid = (l + r) / 2;
            int qmid = query((long long) mid * pow(10, digit));
            if (initDigitSum < qmid) {
                l = mid + 1;
            } else {
                binans = mid;
                r = mid - 1;
            }
        }
        
        ans += to_string(10 - binans);
    }
    
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        if (ans[i] != '0') ans = ans.substr(i, ans.size() - i);
    }
    cout<<"answer "<<ans<<endl;
    
    
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3728kb

input:

6
6
11
4
12
6
11
13
5
6
11
13
14
6
15
15
15
15
15
15
15
15
15
15
15
16
23
22
20

output:

query 0
query 9
query 5
query 7
query 6
query 90
query 50
query 70
query 80
query 900
query 500
query 700
query 800
query 900
query 9000
query 90000
query 900000
query 9000000
query 90000000
query 900000000
query 9000000000
query 90000000000
query 900000000000
query 9000000000000
query 9000000000000...

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3724kb

input:

89
89
85
91
92
93
89
85
91
83
89
94
87
95
89
94
96
97
89
89
94
87
86
80
89
85
82
81
89
94
87
86
89
94
96
97
89
89
85
91
92
84
89
94
87
86
89
85
91
92
84
89
85
91
83
89
85
82
90
90
70
87
85

output:

query 0
query 9
query 5
query 2
query 3
query 4
query 90
query 50
query 20
query 30
query 900
query 500
query 700
query 600
query 9000
query 5000
query 7000
query 8000
query 9000
query 90000
query 50000
query 70000
query 60000
query 900000
query 9000000
query 5000000
query 2000000
query 1000000
quer...

result:

wrong answer wrong guess: 375  actual: 993187646149241375