QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#296444 | #5471. Interactive Number Guessing | MuntherCarrot | WA | 1ms | 3616kb | C++14 | 1023b | 2024-01-03 02:15:12 | 2024-01-03 02:15:12 |
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 < 18; 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: 3616kb
input:
6 11 8 7 11 8 7 11 8 7 11 8 7 11 8 7 11 8 7 11 8 7 11 8 7 11 8 7 11 8 7 74 76 77 78 74 67 77 78 65 58 68 69 56 49 59 60 47 40 50 51 38 31 41 42 29 22 32 33 20 13 21
output:
query 0 query 5 query 2 query 1 query 50 query 20 query 10 query 500 query 200 query 100 query 5000 query 2000 query 1000 query 50000 query 20000 query 10000 query 500000 query 200000 query 100000 query 5000000 query 2000000 query 1000000 query 50000000 query 20000000 query 10000000 query 500000000 ...
result:
wrong answer wrong guess: 10900000020 actual: 123