日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CodeForces - 1245A Good ol' Numbers Coloring (思维)

發布時間:2023/12/15 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CodeForces - 1245A Good ol' Numbers Coloring (思维) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Codeforces Round #597 (Div. 2

Consider the set of all nonnegative integers:?0,1,2,…. Given two integers?a?and?b?(1≤a,b≤104). 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≥a?and?i?a?is colored white,?i?is also colored white;
  • if?i≥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).

Input

The first line of input contains a single integer?t?(1≤t≤100) — the number of test cases in the input. Then?t?lines follow, each line contains two space-separated integers?a?and?b?(1≤a,b≤104).

Output

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).

Example

Input

4 10 10 1 10 6 9 7 3

Output

Infinite Finite Infinite Finite

?這就是模擬的輾轉相減的求最大公約數的算法。最大公約數是1,就能遍歷每一個點,即全是白點,不然就全是黑點。

#include<cstdio> #include<cstring> #include<queue> #include<algorithm> #include<vector> #include<iostream> using namespace std; int main() {int T;scanf("%d",&T);while(T--){int x,y;cin>>x>>y;if(__gcd(x,y)==1) puts("Finite");else puts("Infinite");}return 0; }

?

總結

以上是生活随笔為你收集整理的CodeForces - 1245A Good ol' Numbers Coloring (思维)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。