QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#296441#5471. Interactive Number GuessingMuntherCarrotWA 1ms3568kbC++141022b2024-01-03 02:08:012024-01-03 02:08:01

Judging History

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

  • [2024-01-03 02:08:01]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3568kb
  • [2024-01-03 02:08:01]
  • 提交

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);
    ll digSum = ask(0);
    ll ans = 0;
    for(ll i = 0; i < 2; i++){
        ll l = 1, r = 9, x = 10;
        while(l <= r){
            ll mid = (l + r) / 2;
            if(ask(mid * _pow(10, i)) <= digSum + mid){
                r = mid - 1;
                x = mid;
            }
            else l = mid + 1;
        }
        ans += (10ll - x) * _pow(10, i);
    }
    cout.flush() << "answer " << ans << endl;
    return 0;
}
// by me

詳細信息

Test #1:

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

input:

6
11
8
7
11
8
7

output:

query 0
query 5
query 2
query 1
query 50
query 20
query 10
answer 99

result:

wrong answer wrong guess: 99  actual: 123