QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#298283 | #5471. Interactive Number Guessing | Rifal | TL | 1ms | 3496kb | C++17 | 1.1kb | 2024-01-05 22:34:35 | 2024-01-05 22:34:35 |
Judging History
answer
#include <bits/stdc++.h>
#include <fstream>
//12#define endl '\n'
#define mod 10000000000
#define INF 1000000000
#define INF2 2000000000000000000
//#define ll long long
///#define cin fin
///#define cout fout
using namespace std;
double const EPS = 1e-14;
///ofstream fout("herding.out");
///ifstream fin("herding.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
cout << "query " << 0 << endl; long long ans = 0, sum = 0, num = 0; cin >> ans;
long long cur = 1;
while(sum < ans) {
long long l = 0, r = 9;
long long best;
while(l <= r) {
long long mid = (l+r)/2ll;
cout << "query " << mid * cur << endl;
long long y; cin >> y;
if(y <= ans) {
best = mid;
r = mid-1;
}
else {
l = mid+1;
}
}
if(best > 0) best = 10 - best;
sum += best;
/// cout << best << ' ' << sum << endl;
num += best * cur;
cur *= 10ll;
}
cout << "answer " << num << endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3496kb
input:
6 10 4 11 12 10 13 5 10 13 14 6
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 answer 123
result:
ok correct
Test #2:
score: -100
Time Limit Exceeded
input:
89 93 87 85 84 90 91 83 93 87 94 95 93 96 97 89 93 87 94 86 93 96 79 84 81 89 93 87 94 86 93 96 97 89 84 90 91 92 93 87 94 86 84 90 91 92 84 90 91 83 84 90 82 93 96 97 89 93 69 94 95 75 72 89 84 81 89
output:
query 0 query 4 query 7 query 5 query 40 query 10 query 20 query 30 query 400 query 700 query 500 query 600 query 4000 query 7000 query 8000 query 9000 query 40000 query 70000 query 50000 query 60000 query 400000 query 700000 query 800000 query 4000000 query 1000000 query 0 query 40000000 query 7000...