CF2174E1.Game of Scientists (Version 1)
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The two versions have different constraints on k, c. Solving one of the two versions does not necessarily solve the other. You may want to read both versions. Hacks are disabled in both versions.
This is an interactive problem.
During the time of the Ottoman Empire, many scientists were at work. You decided to study their daily life and stumbled upon an interesting game that was popular at that time. One scientist would think of an integer x, such that 1≤x≤c. Another scientist would try to guess it. He could specify the base of the numeral system 2≤b≤c and would receive as a response the sum of the digits of the number x in base b, if x≥b, or −1 if x<b.
You wrote a program that can think of a number x and respond to the question. Now you want to play with it and learn to guess using ≤k queries.
两个版本对 k、c 的约束条件不同。解决其中任一版本并不必然意味着解决了另一版本。建议您阅读两个版本。两个版本均禁用 Hack。
这是一个交互式问题。
在奥斯曼帝国时期,许多科学家都在从事研究工作。您决定研究他们的日常生活,并偶然发现了一款当时广为流行的游戏。一名科学家会想出一个整数 x,满足 1≤x≤c;另一名科学家则尝试猜出该数。他可以指定一个进制 b(满足 2≤b≤c),并收到如下响应:若 x≥b,则返回 x 在 b 进制下的各位数字之和;若 x<b,则返回 −1。
您编写了一个程序,该程序能随机选定一个数 x 并对查询作出响应。现在您希望与该程序进行游戏,并学会仅用 ≤k 次查询就猜出 x。
输入格式
The first line contains three integers t, k, c (1≤t≤104, k=4, c=4⋅1018). You must guess the number from 1 to c t times, using ≤k queries. All t games will be played consecutively and are independent.
第一行包含三个整数 t、k、c(1≤t≤104,k=4,c=4⋅1018)。你需要在 t 轮游戏中,每轮从 1 到 c 的范围内猜出一个数,且每轮至多使用 k 次询问。所有 t 轮游戏将依次进行,且相互独立。
输入输出样例
输入#1
3 4 4000000000000000000 1 1 7 1 -1 1 -1 6 6 1
输出#1
? 10 ? 1000 ? 2 ! 1000000 ? 2 ! 1 ? 100 ? 10 ? 5 ! 42
说明/提示
In the first game, the hidden number is 100000010=1001000=111101000010010000002. The sums of digits are 1, 1, and 7 in these bases.
In the second game, the hidden number is 1. The query with b=2 returns −1.
In the third game, the hidden number is 4210=1325.
在第一局游戏中,隐藏的数字是 100000010=1001000=111101000010010000002。这些进制下各位数字之和分别为 1、1 和 7。
在第二局游戏中,隐藏的数字是 1。当查询 b=2 时,返回值为 −1。
在第三局游戏中,隐藏的数字是 4210=1325。
输入解题思路,AI测评打分。不知道怎么写?