CF167C.Wizards and Numbers

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In some country live wizards. They love playing with numbers.

The blackboard has two numbers written on it — a and b. The order of the numbers is not important. Let's consider a ≤ b for the sake of definiteness. The players can cast one of the two spells in turns:

  • Replace b with b - a__k. Number k can be chosen by the player, considering the limitations that k > 0 and b - a__k ≥ 0. Number k is chosen independently each time an active player casts a spell.
  • Replace b with b mod a.

If a > b, similar moves are possible.

If at least one of the numbers equals zero, a player can't make a move, because taking a remainder modulo zero is considered somewhat uncivilized, and it is far too boring to subtract a zero. The player who cannot make a move, loses.

To perform well in the magic totalizator, you need to learn to quickly determine which player wins, if both wizards play optimally: the one that moves first or the one that moves second.

某个国家住着一些巫师。他们喜欢玩数字游戏。

黑板上写着两个数字——aa 和 bb。两数的书写顺序无关紧要;为明确起见,不妨设 a≤ba \leq b。两名玩家轮流施放以下两种咒语之一:

  • 将 bb 替换为 b−akb - a k。其中整数 kk 由当前行动的玩家自主选择,需满足限制条件:k>0k > 0 且 b−ak≥0b - a k \geq 0。每次施放该咒语时,kk 均独立选定。
  • 将 bb 替换为 b mod ab \bmod a。

若 a>ba > b,则可进行类似操作(即替换较大的数)。

若两个数中至少有一个为零,则当前玩家无法进行任何操作——因为对零取模被视为某种不文明行为,而从某数中减去零又过于乏味。无法进行操作的玩家判负。

为了在魔法竞猜大赛中取得好成绩,你需要快速判断:当双方巫师均采取最优策略时,先手玩家还是后手玩家获胜。

输入格式

The first line contains a single integer t — the number of input data sets (1 ≤ t ≤ 104). Each of the next t lines contains two integers a, b (0 ≤ a, b ≤ 1018). The numbers are separated by a space.

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.

第一行包含一个整数 tt —— 输入数据组的数量(1 ≤ t ≤ 1041 \leq t \leq 10^4)。接下来的 tt 行中,每行包含两个整数 aa、bb(0 ≤ a, b ≤ 10180 \leq a,\,b \leq 10^{18}),两数之间以空格分隔。

在 C++ 中,请勿使用 %lld 格式说明符读取或写入 64 位整数。推荐使用 cin、cout 流,或 %I64d 格式说明符。

输出格式

For any of the t input sets print "First" (without the quotes) if the player who moves first wins. Print "Second" (without the quotes) if the player who moves second wins. Print the answers to different data sets on different lines in the order in which they are given in the input.

对于每组输入数据,若先手玩家获胜,则输出 “First”(不含引号);若后手玩家获胜,则输出 “Second”(不含引号)。请按输入中给出的顺序,将各组数据的答案分别输出在不同的行上。

输入输出样例

  • 输入#1

    4
    10 21
    31 10
    0 1
    10 30

    输出#1

    First
    Second
    Second
    First

说明/提示

In the first sample, the first player should go to (11,10). Then, after a single move of the second player to (1,10), he will take 10 modulo 1 and win.

In the second sample the first player has two moves to (1,10) and (21,10). After both moves the second player can win.

In the third sample, the first player has no moves.

In the fourth sample, the first player wins in one move, taking 30 modulo 10.

在第一个样例中,先手玩家应移动到 (11,10)(11,10)。随后,后手玩家仅需一步移动到 (1,10)(1,10),即可计算 10 mod 110 \bmod 1 并获胜。

在第二个样例中,先手玩家有两种走法:移动到 (1,10)(1,10) 或 (21,10)(21,10)。但无论选择哪一种,后手玩家均可获胜。

在第三个样例中,先手玩家无法进行任何移动。

在第四个样例中,先手玩家可在一步内获胜,即计算 30 mod 1030 \bmod 10。

输入解题思路,AI测评打分。不知道怎么写?

首页