306734: CF1245A. Good ol' Numbers Coloring

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Good ol' Numbers Coloring

题意翻译

## 题目描述 对于一个非负整数的数列$0,1,2...$,给定两个整数$a,b(1\le a,b\le10^4)$,我们把每个数从小到大染色 每个数字只能被染成黑白两种颜色,而且对$i$染色的规则如下 - 如果$i=0$,则染为白色 - 如果$i\ge a$且$i-a$是白色的,则染为白色 - 如果$i\ge b$且$i-b$是白色的,则染为白色 - 否则染为黑色 举个例子,如果$a=3,b=5$,那么这个序列的染色情况就是(0代表白色,1代表黑色) $$0,1,1,0,1,0,0,1,0,0,...$$ 注意: - 有可能无限多个数被染为黑色。举个例子,当$a=10,b=10$的时候,只有$10$的倍数是白色的,其余数都是黑色 - 也有可能有限多个数被染为黑色。再举个例子,当$a=1,b=10$的时候,没有一个数是黑色的。 你的任务是判断对于每个$a,b$,数列的黑色数是不是无限的。 如果有无限个数是黑色的,则输出$Infinite$(不含引号)。否则输出$Finite$(不含引号)。 ## 输入格式 第一行输入一个$t(1\le t\le 100)$,$t$是数据组数。接下来$t$,每行输入两个数$a,b$,意义和题目描述一样。 ## 输出格式 对于每一组测试数据,输出$Infinite$或$Finite$(不含引号)。输出不区分大小写(就是说$infinite$,$inFiNite$ 或 $finiTE$都是答案)

题目描述

Consider the set of all nonnegative integers: $ {0, 1, 2, \dots} $ . Given two integers $ a $ and $ b $ ( $ 1 \le a, b \le 10^4 $ ). We paint all the numbers in increasing number first we paint $ 0 $ , then we paint $ 1 $ , then $ 2 $ and so on. Each number is painted white or black. We paint a number $ i $ according to the following rules: - if $ i = 0 $ , it is colored white; - if $ i \ge a $ and $ i - a $ is colored white, $ i $ is also colored white; - if $ i \ge b $ and $ i - b $ is colored white, $ i $ is also colored white; - if $ i $ is still not colored white, it is colored black. In this way, each nonnegative integer gets one of two colors. For example, if $ a=3 $ , $ b=5 $ , then the colors of the numbers (in the order from $ 0 $ ) are: white ( $ 0 $ ), black ( $ 1 $ ), black ( $ 2 $ ), white ( $ 3 $ ), black ( $ 4 $ ), white ( $ 5 $ ), white ( $ 6 $ ), black ( $ 7 $ ), white ( $ 8 $ ), white ( $ 9 $ ), ... Note that: - It is possible that there are infinitely many nonnegative integers colored black. For example, if $ a = 10 $ and $ b = 10 $ , then only $ 0, 10, 20, 30 $ and any other nonnegative integers that end in $ 0 $ 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 = 1 $ and $ b = 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).

输入输出格式

输入格式


The first line of input contains a single integer $ t $ ( $ 1 \le t \le 100 $ ) — the number of test cases in the input. Then $ t $ lines follow, each line contains two space-separated integers $ a $ and $ b $ ( $ 1 \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).

输入输出样例

输入样例 #1

4
10 10
1 10
6 9
7 3

输出样例 #1

Infinite
Finite
Infinite
Finite

Input

题意翻译

## 题目描述 对于一个非负整数的数列$0,1,2...$,给定两个整数$a,b(1\le a,b\le10^4)$,我们把每个数从小到大染色 每个数字只能被染成黑白两种颜色,而且对$i$染色的规则如下 - 如果$i=0$,则染为白色 - 如果$i\ge a$且$i-a$是白色的,则染为白色 - 如果$i\ge b$且$i-b$是白色的,则染为白色 - 否则染为黑色 举个例子,如果$a=3,b=5$,那么这个序列的染色情况就是(0代表白色,1代表黑色) $$0,1,1,0,1,0,0,1,0,0,...$$ 注意: - 有可能无限多个数被染为黑色。举个例子,当$a=10,b=10$的时候,只有$10$的倍数是白色的,其余数都是黑色 - 也有可能有限多个数被染为黑色。再举个例子,当$a=1,b=10$的时候,没有一个数是黑色的。 你的任务是判断对于每个$a,b$,数列的黑色数是不是无限的。 如果有无限个数是黑色的,则输出$Infinite$(不含引号)。否则输出$Finite$(不含引号)。 ## 输入格式 第一行输入一个$t(1\le t\le 100)$,$t$是数据组数。接下来$t$,每行输入两个数$a,b$,意义和题目描述一样。 ## 输出格式 对于每一组测试数据,输出$Infinite$或$Finite$(不含引号)。输出不区分大小写(就是说$infinite$,$inFiNite$ 或 $finiTE$都是答案)

加入题单

算法标签: