QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#305779#5471. Interactive Number GuessingAliMark71WA 1ms3700kbC++231.5kb2024-01-15 23:43:582024-01-15 23:43:58

Judging History

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

  • [2024-01-15 23:43:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3700kb
  • [2024-01-15 23:43:58]
  • 提交

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 = 8, 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

query 0
query 9
query 4
query 6
query 7
query 90
query 40
query 60
query 70
query 80
query 900
query 400
query 600
query 700
query 800
query 9000
query 90000
query 900000
query 9000000
query 90000000
query 900000000
query 9000000000
query 90000000000
query 900000000000
query 9000000000000
query 9000...

result:

wrong answer wrong guess: 1123  actual: 123