QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226281#5471. Interactive Number GuessingOAleksaWA 1ms3608kbC++14842b2023-10-25 19:24:052023-10-25 19:24:05

Judging History

你现在查看的是最新测评结果

  • [2023-10-25 19:24:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2023-10-25 19:24:05]
  • 提交

answer

#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
#define int long long
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt--) {
    	auto Ask = [&](int x) {
    		cout << "query " << x << endl;
    		int r;
    		cin >> r;
    		return r;
    	};
    	int x = Ask(0);
    	int p = 1, ans = 0;
    	for (int i = 1;i <= 18;i++) {
    		int l = 0, r = 9, id;
    		while (l <= r) {
    			int mid = (l + r) / 2;
    			int rz = Ask(mid * p);
    			if (x + mid == rz)
    				l = mid + 1;
    			else {
    				id = mid;
    				r = mid - 1;
    			}
    		}
    		cout << id << endl;
    		ans += (10 - id) * p;
    		p *= 10;
    	}
    	cout << "answer" << ans << endl;
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3608kb

input:

6
10
4
11
12

output:

query 0
query 4
query 7
query 5
query 6
7
query 40

result:

wrong answer invalid type: 7