codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1245A.md (2340B)


      1 Source: https://codeforces.com/problemset/problem/1245/A
      2 
      3 A. Good ol' Numbers Coloring
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 Each number is painted white or black. We paint a number $i$ according to the following rules:
     24 
     25 * if $i = 0$, it is colored white;
     26 * if $i \ge a$ and $i - a$ is colored white, $i$ is also colored white;
     27 * if $i \ge b$ and $i - b$ is colored white, $i$ is also colored white;
     28 * if $i$ is still not colored white, it is colored black.
     29 
     30 In this way, each nonnegative integer gets one of two colors.
     31 
     32 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$), ...
     33 
     34 Note that:
     35 
     36 * 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.
     37 * 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.
     38 
     39 Your task is to determine whether or not the number of nonnegative integers colored black is infinite.
     40 
     41 If there are infinitely many nonnegative integers colored black, simply print a line containing "Infinite" (without the quotes). Otherwise, print "Finite" (without the quotes).
     42 
     43 Input
     44 
     45 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$).
     46 
     47 Output
     48 
     49 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).
     50 
     51 Example
     52 
     53 Input
     54 
     55 ```
     56 4
     57 10 10
     58 1 10
     59 6 9
     60 7 3
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 Infinite
     67 Finite
     68 Infinite
     69 Finite
     70 ```