链接:

https://codeforces.com/contest/1245/problem/A

题意:

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

思路:

猜的GCD, 考虑ax+by = gcd(a, b),所以要整除。

代码:

#include<bits/stdc++.h>
using namespace std; int main()
{
ios::sync_with_stdio(false);
int t;
cin >> t;
while(t--)
{
int a, b;
cin >> a >> b;
if (__gcd(a, b) != 1)
puts("Infinite");
else
puts("Finite");
} return 0;
}

Codeforces Round #597 (Div. 2) A. Good ol' Numbers Coloring的更多相关文章

  1. Codeforces Round #597 (Div. 2)

    A - Good ol' Numbers Coloring 题意:有无穷个格子,给定 \(a,b\) ,按以下规则染色: \(0\) 号格子白色:当 \(i\) 为正整数, \(i\) 号格子当 \( ...

  2. Codeforces Round #597 (Div. 2) D. Shichikuji and Power Grid

    链接: https://codeforces.com/contest/1245/problem/D 题意: Shichikuji is the new resident deity of the So ...

  3. Codeforces Round #597 (Div. 2) C. Constanze's Machine

    链接: https://codeforces.com/contest/1245/problem/C 题意: Constanze is the smartest girl in her village ...

  4. Codeforces Round #597 (Div. 2) B. Restricted RPS

    链接: https://codeforces.com/contest/1245/problem/B 题意: Let n be a positive integer. Let a,b,c be nonn ...

  5. Codeforces Round #597 (Div. 2) D. Shichikuji and Power Grid 题解 最小生成树

    题目链接:https://codeforces.com/contest/1245/problem/D 题目大意: 平面上有n座城市,第i座城市的坐标是 \(x[i], y[i]\) , 你现在要给n城 ...

  6. 计算a^b==a+b在(l,r)的对数Codeforces Round #597 (Div. 2)

    题:https://codeforces.com/contest/1245/problem/F 分析:转化为:求区间内满足a&b==0的对数(解释见代码) ///求满足a&b==0在区 ...

  7. Codeforces Round #597 (Div. 2) F. Daniel and Spring Cleaning 数位dp

    F. Daniel and Spring Cleaning While doing some spring cleaning, Daniel found an old calculator that ...

  8. Codeforces Round #597 (Div. 2) E. Hyakugoku and Ladders 概率dp

    E. Hyakugoku and Ladders Hyakugoku has just retired from being the resident deity of the South Black ...

  9. Codeforces Round #597 (Div. 2) D. Shichikuji and Power Grid 最小生成树

    D. Shichikuji and Power Grid</centerD.> Shichikuji is the new resident deity of the South Blac ...

随机推荐

  1. Elasticsearch配置安装

    跨域  elasticsearch-head连接es时会提示连接失败,有可能就是没有开启跨域 http.cors.enabled 是否支持跨域,默认为false http.cors.allow-ori ...

  2. Redis持久化RDB、AOF

    持久化的意思就是保存,保存到硬盘.第一次接触这个词是在几年前学习EF. 为什么要持久化 redis定义:Redis是一个开源(BSD许可),内存存储的数据结构服务器,可用作数据库,高速缓存和消息队列代 ...

  3. 【转】MySQL中EXISTS的用法

    原文链接:https://www.cnblogs.com/qlqwjy/p/8598091.html 比如在Northwind数据库中有一个查询为 SELECT c.CustomerId,Compan ...

  4. CF731E Funny Game

    题目描述 一个长度为 N 的序列 ai ,双方轮流操作 每次的操作是选择一个长度大于 1 的前缀,计算它的和 s ,然后 用 s 替换它的前缀,同时当前玩家获得 s 的分数. 当只剩下一个元素,游戏结 ...

  5. Istio技术与实践6:Istio如何为服务提供安全防护能力

    凡是产生连接关系,就必定带来安全问题,人类社会如此,服务网格世界,亦是如此. 今天,我们就来谈谈Istio第二主打功能---保护服务. 那么,便引出3个问题: l  Istio凭什么保护服务? l  ...

  6. Linux修改主机名方法

    [root@lyx ~]# vim /etc/hosts   vim代表修改,进入hosts文件进行添加192.168.10.128 hadoop128 [root@lyx ~]# hostname ...

  7. wcf Origin

    WebHttpBinding bd = new WebHttpBinding(); //WebServiceHost sh = new WebServiceHost(typeof(Bl_x), new ...

  8. Go 互斥锁(sync.Mutex)和 读写锁(sync.RWMutex)

    什么时候需要用到锁? 当程序中就一个线程的时候,是不需要加锁的,但是通常实际的代码不会只是单线程,所以这个时候就需要用到锁了,那么关于锁的使用场景主要涉及到哪些呢? 多个线程在读相同的数据时 多个线程 ...

  9. wepy框架 怎么在template模板中使用函数

    呵呵.介绍说是类似vue,用起来真累人,就想在模板中使用个函数都要查N久的文档才知道. 具体要怎么操作呢? 要先创建个wxs脚本文件,在里面定义函数或其它的,然后在页面或组件中引入这文件,就可以在模板 ...

  10. c语言二进制、八进制、十六进制

    int binary = 0b01000010; //二进制 printf("%d\n", binary); //十进制 printf("0x%x\n", 0x ...