QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296918#5471. Interactive Number GuessingNaserWA 1ms3828kbC++171.5kb2024-01-03 19:46:572024-01-03 19:46:59

Judging History

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

  • [2024-01-03 19:46:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3828kb
  • [2024-01-03 19:46:57]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define pii pair<int,int>
#define vint vector<int>
#define vpii vector<pii>
#define pb push_back
#define se second
#define fi first
#define all(x) x.begin(), x.end()
#define graph vector<vint>
using namespace std;
const int N = (int)1e5 + 69;
const int mod = (int)1e4 + 7;
const int naser = 3999, tourist = 3662;
int INF = INT_MAX;
int power(int a, int b) { int ans = 1; while (b) { if (b % 2) ans *= a; a *= a; b /= 2; } return ans; }
int gcd(int a, int b) { if (b == 0)return a;return gcd(b, a % b); }

//int x = 999999999999999999;
//int digsum(int xx) {
//    int ans = 0;
//    while (xx) {
//        ans += xx % 10;
//        xx /= 10;
//    }
//    return ans;
//}
int query(int a) {
    cout << "query " << a << endl;
    cout.flush();
    int ans = 0;
    //ans = digsum(x + a);
    cin >> ans;
    return ans;
}

int32_t main() {

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    string ans = "answer ";
    int sum = query(0);
    for (int i = 0; i < 18; i++) {
        int dig = power(10, i),num = -1;
        int l = 0, r = 9;
        while (l <= r) {
            int mid = (l + r) / 2;
            int tmp = query(mid * dig);
            if (sum + mid == tmp)
                l = mid + 1, num = mid;
            else
                r = mid - 1;
        }
        ans.push_back('0' + 9 - num);
    }
    reverse(ans.begin() + 7, ans.end());
    cout << ans << endl;
    cout.flush();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

query 0
query 4
query 7
query 5
query 6
query 40
query 70
query 80
query 400
query 700
query 800
query 900
query 4000
query 7000
query 8000
query 9000
query 40000
query 70000
query 80000
query 90000
query 400000
query 700000
query 800000
query 900000
query 4000000
query 7000000
query 8000000
query 9...

result:

wrong answer format  Expected integer, but "000000000000000123" found