QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#305779 | #5471. Interactive Number Guessing | AliMark71 | WA | 1ms | 3700kb | C++23 | 1.5kb | 2024-01-15 23:43:58 | 2024-01-15 23:43:58 |
Judging History
answer
//
// main.cpp
// GeneralCompetitiveProgramming
//
// Created by Ali AlSalman on 12/07/2023.
//
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <climits>
#define endl '\n'
using namespace std;
int query(long long n) {
cout<<"query "<<n<<endl<<flush;
int x;
cin>>x;
return x;
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int initDigitSum = query(0);
string ans = "";
for (int digit = 0; digit < 18; digit++) {
if (query(9 * pow(10, digit)) != initDigitSum) {
ans += '0';
continue;
}
int l = 1, r = 8, binans = -1;
while (l <= r) {
int mid = (l + r) / 2;
int qmid = query((long long) mid * pow(10, digit));
if (initDigitSum <= qmid) {
l = mid + 1;
} else {
binans = mid;
r = mid - 1;
}
}
ans += to_string(10 - binans);
}
reverse(ans.begin(), ans.end());
for (int i = 0; i < ans.size(); i++) {
if (ans[i] != '0') ans = ans.substr(i, ans.size() - i);
}
cout<<"answer "<<ans<<endl;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3700kb
input:
6 6 10 12 4 6 10 12 13 5 6 10 12 13 14 15 15 15 15 15 15 15 15 15 15 15 16 23 22 20
output:
query 0 query 9 query 4 query 6 query 7 query 90 query 40 query 60 query 70 query 80 query 900 query 400 query 600 query 700 query 800 query 9000 query 90000 query 900000 query 9000000 query 90000000 query 900000000 query 9000000000 query 90000000000 query 900000000000 query 9000000000000 query 9000...
result:
wrong answer wrong guess: 1123 actual: 123