codeforce#483div2C-Finite or not?数论,GCD
传送门:http://codeforces.com/contest/984/problem/C
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iterator>
#include <cmath>
using namespace std; typedef long long ll; int n;
ll p,q,b; ll gcd(ll a,ll b)
{
return b==?a:gcd(b,a%b);
}
int main(){
scanf("%d", &n);
while(n--)
{
scanf("%lld%lld%lld", &p, &q, &b);
ll tmp = gcd(p,q);
if(p==)
{
puts("Finite");
continue;
}
p/=tmp;q/=tmp;
tmp = gcd(q,b);
while(tmp!=)
{
while(q%tmp == )q/=tmp; //这不要加上while才不会tle
tmp = gcd(q,b);
}
if(q==)puts("Finite");
else puts("Infinite"); } return ;
}
codeforce#483div2C-Finite or not?数论,GCD的更多相关文章
- UVA.12716 GCD XOR (暴力枚举 数论GCD)
		
UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...
 - CF984 C. Finite or not?【数论/GCD】
		
[链接]:CF [题意]:n组样例,对于每组样例,给你三个数p q b,问你p/q在b进制下是不是一个有限小数,是的话输出Finite,否则输出Infinite. [分析]:b的过程是对q约分,那么只 ...
 - 假的数论gcd,真的记忆化搜索(Codeforce 1070- A. Find a Number)
		
题目链接: 原题:http://codeforces.com/problemset/problem/1070/A 翻译过的训练题:https://vjudge.net/contest/361183#p ...
 - cf C. Finite or not?    数论
		
You are given several queries. Each query consists of three integers pp, qq and bb. You need to answ ...
 - 【cf 483 div2 -C】Finite or not?(数论)
		
链接:http://codeforces.com/contest/984/problem/C 题意 三个数p, q, b, 求p/q在b进制下小数点后是否是有限位. 思路 题意转化为是否q|p*b^x ...
 - CF1025B Weakened Common Divisor【数论/GCD/思维】
		
#include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include ...
 - HDU - 5584 LCM Walk (数论 GCD)
		
A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. No ...
 - HDU 1722 Cake (数论 gcd)(Java版)
		
Big Number 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1722 ——每天在线,欢迎留言谈论. 题目大意: 给你两个数 n1,n2 . 然后 ...
 - 数论----gcd和lcm
		
gcd即最大公约数,lcm即最小公倍数. 首先给出a×b=gcd×lcm 证明:令gcd(a,b)=k,a=xk,b=yk,则a×b=x*y*k*k,而lcm=x*y*k,所以a*b=gcd*lcm. ...
 - hdu 5505(数论-gcd的应用)
		
GT and numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
 
随机推荐
- C#   二维码的生成
			
nuget 搜索qrcodenet,然后选择下载gma.qrcodenet public partial class Form1 : Form { public Form1() { Initializ ...
 - restapi(3)- MongoDBEngine : MongoDB Scala编程工具库
			
最近刚好有同事在学习MongoDB,我们讨论过MongoDB应该置于服务器端然后通过web-service为客户端提供数据的上传下载服务.我们可以用上节讨论的respapi框架来实现针对MongoDB ...
 - Linux 常用命令及详解
			
1. type :查询命令 是否属于shell解释器2. help : 帮助命令3. man : 为所有用户提供在线帮助4. ls : 列表显示目录内的文件及目录-l 以长格式显 ...
 - 案例实战:每日上亿请求量的电商系统,JVM年轻代垃圾回收参数如何优化?
			
出自:http://1t.click/7TJ 目录: 案例背景引入 特殊的电商大促场景 抗住大促的瞬时压力需要几台机器? 大促高峰期订单系统的内存使用模型估算 内存到底该如何分配? 新生代垃圾回收优化 ...
 - kali Metasploit 连接 Postgresql 默认密码
			
使用 metasploit 时, 1. 启动 postgresql service postgresql start 2. 自行测试 postgresql 是否安装成功 根据需要,自行 修改 post ...
 - Spring IoC源码解析之invokeBeanFactoryPostProcessors
			
一.Bean工厂的后置处理器 Bean工厂的后置处理器:BeanFactoryPostProcessor(触发时机:bean定义注册之后bean实例化之前)和BeanDefinitionRegistr ...
 - c语言ld returned 1 exit status😂
			
在复习c语言过程中遇到, 问题:reverseLinkedList.exe: Permission denied collect2.exe: error: ld returned 1 exit sta ...
 - JavaScript数据结构——图的实现
			
在计算机科学中,图是一种网络结构的抽象模型,它是一组由边连接的顶点组成.一个图G = (V, E)由以下元素组成: V:一组顶点 E:一组边,连接V中的顶点 下图表示了一个图的结构: 在介绍如何用Ja ...
 - 带图标和多行显示的ListBox
			
源码https://www.codeproject.com/Articles/15464/Extending-the-ListBox-to-show-more-complex-items 定义控件 u ...
 - 为什么选择B+树作为数据库索引结构?
			
背景 首先,来谈谈B树.为什么要使用B树?我们需要明白以下两个事实: [事实1] 不同容量的存储器,访问速度差异悬殊.以磁盘和内存为例,访问磁盘的时间大概是ms级的,访问内存的时间大概是ns级的.有个 ...