3345. 猜猜看

单点时限: 2.0 sec

内存限制: 256 MB

你想了一个数,要让我猜一猜。

  • 这个数必须在 $−10^9$ 到 $10^9$ 之间。
  • 这个数是整数。
  • 我每猜一个数,你都要回答我大了 (big) 或者小了 (small) 或者正好 (equal)。
  • 我猜的数一定是 $−10^9$ 和 $10^9$ 之间的整数。
  • 你不能上述违反游戏规则,或者想一个根本不存在的数。
  • 我最终肯定是能猜出来的,在我猜出来之前,你不能中途离场(退出)。

如果我在 $30$ 次之内(包括 $30$ 次)都没有猜出来,你就赢了。

我是这样猜数的:

l = -1e9
r = 1e9
while l < r:
    guess a random number in [l,r] and let it be m
    if it is too big:
        r = m - 1
    if it is too small:
        l = m + 1
    if it is equal:
        bingo and exit
print 'You are kidding me!'

注:题目中用到的 randomrandom uniformly

样例

Input
2
-3
-1
0
Output
big
small
small
equal

提示

这是一个交互题。你要先猜,输出到标准输出流 (stdout)。对于我的回答,你要从标准输入流中读入 (stdin)。

你需要清空缓冲区,在 C 中使用 fflush,C++ 中使用 flushendl,在 Python 中使用 sys.stdout.flush()

你可能会遇到 Idleness Limit Exceeded,这种错误表示你的程序「太闲了」。你可能在等待输入,或者只是超时了(而我并不知道,以为你闲着)。

46 人解决,65 人已尝试。

63 份提交通过,共有 311 份提交。

4.6 EMB 奖励。

创建: 6 年,7 月前.

修改: 6 年,7 月前.

最后提交: 7 月,1 周前.

来源: EOJ Hacking Round #1

题目标签