QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296439#5471. Interactive Number GuessingMuntherCarrotWA 1ms3560kbC++141.0kb2024-01-03 02:04:502024-01-03 02:04:51

Judging History

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

  • [2024-01-03 02:04:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2024-01-03 02:04:50]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
// #define endl '\n'
#define all(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
#define INFLL (ll)0x3f3f3f3f3f3f3f3f
const int MOD = 1e9 + 7, SZ = 1e5 + 10;
ll _pow(ll b, ll p){
	ll res = 1;
	while(p){
		if(p & 1)
			res = (res * b) % MOD;
		b = (b * b) % MOD;
		p >>= 1;
	}
	return res;
}
int ask(ll x){
    cout.flush() << "query " << x << endl;
    int ans;
    cin >> ans;
    return ans;
}
int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int digSum = ask(0);
    ll ans = 0;
    for(ll i = 0; i < 2; i++){
        int res;
        int l = 1, r = 9, x = 10;
        while(l <= r){
            int mid = (l + r) / 2;
            if(ask((ll)mid * _pow(10, i)) <= digSum){
                r = mid - 1;
                x = mid;
            }
            else l = mid + 1;
        }
        ans += (ll)(10 - x) * _pow(10, i);
    }
    cout.flush() << "answer " << ans << endl;
    return 0;
}
// by me

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
11
4
12
11
13
5

output:

query 0
query 5
query 7
query 6
query 50
query 70
query 80
answer 23

result:

wrong answer wrong guess: 23  actual: 123