QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296919 | #5471. Interactive Number Guessing | Naser | TL | 0ms | 0kb | C++17 | 1.5kb | 2024-01-03 19:48:20 | 2024-01-03 19:48:21 |
answer
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define pii pair<int,int>
#define vint vector<int>
#define vpii vector<pii>
#define pb push_back
#define se second
#define fi first
#define all(x) x.begin(), x.end()
#define graph vector<vint>
using namespace std;
const int N = (int)1e5 + 69;
const int mod = (int)1e4 + 7;
const int naser = 3999, tourist = 3662;
int INF = INT_MAX;
int power(int a, int b) { int ans = 1; while (b) { if (b % 2) ans *= a; a *= a; b /= 2; } return ans; }
int gcd(int a, int b) { if (b == 0)return a;return gcd(b, a % b); }
//int x = 999999999999999999;
//int digsum(int xx) {
// int ans = 0;
// while (xx) {
// ans += xx % 10;
// xx /= 10;
// }
// return ans;
//}
int query(int a) {
cout << "query " << a << endl;
int ans = 0;
//ans = digsum(x + a);
cin >> ans;
return ans;
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string ans;
int sum = query(0);
for (int i = 0; i < 18; i++) {
int dig = power(10, i),num = -1;
int l = 0, r = 9;
while (l <= r) {
int mid = (l + r) / 2;
int tmp = query(mid * dig);
if (sum + mid == tmp)
l = mid + 1, num = mid;
else
r = mid - 1;
}
ans.push_back('0' + 9 - num);
}
reverse(all(ans));
cout << "answer " << ans << endl;
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded