CF1245A.Good ol' Numbers Coloring

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Consider the set of all nonnegative integers: 0,1,2,…{0, 1, 2, \dots}. Given two integers aa and bb (1≤a,b≤1041 \le a, b \le 10^4). We paint all the numbers in increasing number first we paint 00, then we paint 11, then 22 and so on.

Each number is painted white or black. We paint a number ii according to the following rules:

  • if i=0i = 0, it is colored white;
  • if i≥ai \ge a and i−ai - a is colored white, ii is also colored white;
  • if i≥bi \ge b and i−bi - b is colored white, ii is also colored white;
  • if ii is still not colored white, it is colored black.

In this way, each nonnegative integer gets one of two colors.

For example, if a=3a=3, b=5b=5, then the colors of the numbers (in the order from 00) are: white (00), black (11), black (22), white (33), black (44), white (55), white (66), black (77), white (88), white (99), ...

Note that:

  • It is possible that there are infinitely many nonnegative integers colored black. For example, if a=10a = 10 and b=10b = 10, then only 0,10,20,300, 10, 20, 30 and any other nonnegative integers that end in 00 when written in base 10 are white. The other integers are colored black.
  • It is also possible that there are only finitely many nonnegative integers colored black. For example, when a=1a = 1 and b=10b = 10, then there is no nonnegative integer colored black at all.

Your task is to determine whether or not the number of nonnegative integers colored black is infinite.

If there are infinitely many nonnegative integers colored black, simply print a line containing "Infinite" (without the quotes). Otherwise, print "Finite" (without the quotes).

考虑所有非负整数的集合:{0,1,2,… }\{0, 1, 2, \dots\}。给定两个整数 aa 和 bb(1≤a,b≤1041 \le a, b \le 10^4)。我们按数值递增顺序对所有数字进行染色:首先染 00,然后染 11,接着染 22,依此类推。

每个数字被染成白色或黑色。数字 ii 的染色规则如下:

  • 若 i=0i = 0,则染成白色;
  • 若 i≥ai \ge a 且 i−ai - a 是白色的,则 ii 也染成白色;
  • 若 i≥bi \ge b 且 i−bi - b 是白色的,则 ii 也染成白色;
  • 若 ii 尚未被染成白色,则染成黑色。

如此,每个非负整数均被赋予两种颜色之一。

例如,若 a=3a=3,b=5b=5,则各数字(按从 00 开始的顺序)的颜色为:白色(00),黑色(11),黑色(22),白色(33),黑色(44),白色(55),白色(66),黑色(77),白色(88),白色(99),……

注意:

  • 可能有无穷多个非负整数被染成黑色。例如,若 a=10a = 10 且 b=10b = 10,则只有 0,10,20,300, 10, 20, 30 以及所有十进制表示下末位为 00 的非负整数是白色的;其余整数均为黑色。
  • 也可能仅有有限个非负整数被染成黑色。例如,当 a=1a = 1 且 b=10b = 10 时,不存在任何被染成黑色的非负整数。

你的任务是判断被染成黑色的非负整数的个数是否为无穷。

若被染成黑色的非负整数有无穷多个,则仅输出一行字符串 "Infinite"(不含引号);否则输出 "Finite"(不含引号)。

输入格式

The first line of input contains a single integer tt (1≤t≤1001 \le t \le 100) — the number of test cases in the input. Then tt lines follow, each line contains two space-separated integers aa and bb (1≤a,b≤1041 \le a, b \le 10^4).

输入的第一行包含一个整数 tt(1≤t≤1001 \le t \le 100),表示输入中测试用例的数量。接下来有 tt 行,每行包含两个由空格分隔的整数 aa 和 bb(1≤a,b≤1041 \le a, b \le 10^4)。

输出格式

For each test case, print one line containing either "Infinite" or "Finite" (without the quotes). Output is case-insensitive (i.e. "infinite", "inFiNite" or "finiTE" are all valid answers).

对于每个测试用例,输出一行,包含 "Infinite" 或 "Finite"(不带引号)。输出不区分大小写(即 "infinite"、"inFiNite" 或 "finiTE" 均为有效答案)。

输入输出样例

  • 输入#1

    4
    10 10
    1 10
    6 9
    7 3

    输出#1

    Infinite
    Finite
    Infinite
    Finite

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

首页