Codeforces Round #597 (Div. 2) A. Good ol' Numbers Coloring
链接:
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的更多相关文章
- Codeforces Round #597 (Div. 2)
A - Good ol' Numbers Coloring 题意:有无穷个格子,给定 \(a,b\) ,按以下规则染色: \(0\) 号格子白色:当 \(i\) 为正整数, \(i\) 号格子当 \( ...
- 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 ...
- Codeforces Round #597 (Div. 2) C. Constanze's Machine
链接: https://codeforces.com/contest/1245/problem/C 题意: Constanze is the smartest girl in her village ...
- 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 ...
- Codeforces Round #597 (Div. 2) D. Shichikuji and Power Grid 题解 最小生成树
题目链接:https://codeforces.com/contest/1245/problem/D 题目大意: 平面上有n座城市,第i座城市的坐标是 \(x[i], y[i]\) , 你现在要给n城 ...
- 计算a^b==a+b在(l,r)的对数Codeforces Round #597 (Div. 2)
题:https://codeforces.com/contest/1245/problem/F 分析:转化为:求区间内满足a&b==0的对数(解释见代码) ///求满足a&b==0在区 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- [转帖]Red Hat K8s 关键人物 Grant Shipley 跳槽到 VMware
Red Hat K8s 关键人物 Grant Shipley 跳槽到 VMware https://news.cnblogs.com/n/641944/ 这四小时的工作效率 太无敌了.. 投递人 ...
- IIS清理缓存
服务器突然断电经常会导致IIS中web项目运行不起来问题,各种报XXXX.dll加载失败,解决方法重新发布,如果重新发布也不行可能就是IIS缓存的问题了. 清理IIS缓存方法: 进入以下文件夹吧对应的 ...
- BJFU——205基于顺序存储结构的图书信息表的排序
#include<stdio.h> #include<stdlib.h> #define MAX 1000 typedef struct{ double no; char na ...
- python 并发的开端
目录 网络并发 进程的基础 2.操作系统 操作系统的发展史 多道技术 第二代 1955~1965 磁带存储--批处理系统 第三代集成电路,多道程序系统(1955~1965) 进程的理论(重点) 2.操 ...
- vue的安装配置与项目创建
1,安装vue必须先安装node.js. --------去官网安装node.js 因为npm依赖node.js环境,使用npm的时候需要安装node.js.安装node.js的时候npm会默认安装 ...
- PB学习笔记之随笔
1.根据条件改变字体颜色.if(curdate>=bdate and curdate<edate,rgb(255,0,0),if(sex=1, if(curdate>=mdate, ...
- 组件上使用v-model
组件上使用v-model <input v-model="searchText"> 等价于 <input v-bind:value="searchTex ...
- 怎样查看系统安装的python版本
方法一: 在命令行下使用python -V 方法二: 在命令行下进入python交互模式, 可以在第一行看到python的版本信息
- [v]Linux下安装Git
Ubuntu12.04中默认没有安装Git.需要自行安装. 1. 安装Git 1.1 Ubuntu12.04下 可以使用apt-get方式安装,也可以下载源代码安装[1],我们这里使用apt-git安 ...
- VS 2015 .net UI界面报错总结
一.提示錯誤 解決方法: 右击解决方案点击properties Window Ctrl+W ,P 将Mnaged Pipeline Mode 从Integrated更改为Classic 二.提示錯誤 ...