A13056 | Good ol' Numbers Coloring
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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).
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted