QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#296441 | #5471. Interactive Number Guessing | MuntherCarrot | WA | 1ms | 3568kb | C++14 | 1022b | 2024-01-03 02:08:01 | 2024-01-03 02:08:01 |
Judging History
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
Details
Tip: Click on the bar to expand more detailed information
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