QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#14536. 猜测

Statistics

Alice 和 Bob 正在玩一个游戏。他们每个人的额头上都贴着一张卡片,上面写着一个正整数(Alice 的数是 $a$,Bob 的数是 $b$)。

Alice 和 Bob 只能看到对方额头上的数,但他们都知道这两个数 $a, b$ 都是正整数,且其中一个数是另一个数的两倍。

每一轮中,Alice 和 Bob 轮流尝试猜测自己的数,Alice 先开始。(当 Alice 和 Bob 都完成各自的尝试后,该轮结束。)

他们两个人都足够聪明,且不会犯错。当且仅当他们确切知道自己的数时,他们才会说出答案,否则他们会说“我不知道”。

给定 Alice 和 Bob 额头上的两个数,找出其中一个人在第几轮可以确定并说出自己额头上的正整数。

输入格式

本题包含多组测试数据。

第一行包含一个整数 $T$,表示测试数据的组数($1 \le T \le 10^5$)。

对于每组测试数据,唯一的一行包含两个整数 $a, b$($1 \le a, b \le 10^{18}$)。

保证 $a = 2b$ 或 $b = 2a$ 始终成立。

输出格式

对于每组测试数据,输出两个整数 $r, p$,表示在第 $r$ 轮,玩家 $p$ 可以说出答案。其中 $p = 0$ 代表 Alice,$p = 1$ 代表 Bob。

样例

输入样例 1

3
6 3
1 2
499999999999999999 999999999999999998

输出样例 1

1 0
1 1
1 1

说明

对于第一个样例,Alice 可以看到 Bob 额头上的数,这是一个奇数 $3$。然后她可以发现自己额头上的数必须是 $6$,因为不存在整数 $x$ 满足 $3 = 2x$。

请注意:$a, b$ 的范围仅对你(作为解题者)可见,而游戏中的两位玩家并不知道这个范围。也就是说,当 $a = 5 \times 10^{17}, b = 10^{18}$ 时,即使 $a = 2 \times 10^{18}$ 超出了输入范围,Alice 也不能立即说出她的数。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.