https://atcoder.jp/contests/abc142/tasks/abc142_d

题意

求满足互素条件下的A和B的因子最多有几个

思路:

分解gcd(A,B)的质因子,再加上1;

#include <iostream>
#include<algorithm>
#include<string>
using namespace std;
const int maxn =1e5+;
long long gcd(long long x,long long y)
{
if(y==)return x;
return gcd(y,x%y);
}
int main()
{
long long x,y;
cin >> x >> y;
long long g=gcd(x,y);
long long ans=;
for(long long i=;i<= g / i; i++)
{
if(g%i==)
{
ans++;
while(g%i==) g/=i;
}
}
if(g>) ans++;
cout << ans + <<endl;
return ;
}

D - Disjoint Set of Common Divisors的更多相关文章

  1. Common Divisors CodeForces - 182D || kmp最小循环节

    Common Divisors CodeForces - 182D 思路:用kmp求next数组的方法求出两个字符串的最小循环节长度(http://blog.csdn.net/acraz/articl ...

  2. CF #579 (Div. 3) C.Common Divisors

    C.Common Divisors time limit per test2 seconds memory limit per test256 megabytes inputstandard inpu ...

  3. B - Common Divisors (codeforces)数论算法基本定理,唯一分解定理模板

    You are given an array aa consisting of nn integers. Your task is to say the number of such positive ...

  4. [gcd]Codeforces Common Divisors

    Common Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  5. Codeforces Round #579 (Div. 3) B Equal Rectangles、C. Common Divisors

    B Equal Rectangles 题意: 给你4*n个数,让你判断能不能用这个4*n个数为边凑成n个矩形,使的每个矩形面积相等 题解: 原本是想着用二分来找出来那个最终的面积,但是仔细想一想,那个 ...

  6. <Sicily>Greatest Common Divisors

    一.题目描述 A common divisor for two positive numbers is a number which both numbers are divisible by. It ...

  7. Codeforces182D - Common Divisors(KMP)

    题目大意 如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S1和S2,求它们的公共因子个数 题解 如果它们有公共因子,那么显然它们的最小公共因子肯定是 ...

  8. Codeforces Round #117 (Div. 2) D.Common Divisors(KMP最小循环节)

    http://codeforces.com/problemset/problem/182/D 题意:如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S ...

  9. Common Divisors CodeForces - 1203C

    题意: 给你n个数,让你找出来公因子有多少个.公因子:对于这n个数,都能被这个公因子整除 题解: 只需要找出来这n个数的最大公因子x,然后找出来有多少不同数能把x给整.(因为我们可以保证x可以把这n个 ...

随机推荐

  1. 23.二叉搜索树的后序遍历(python)

    题目描述 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果.如果是则输出Yes,否则输出No.假设输入的数组的任意两个数字都互不相同. 这道题特别傻的地方: 当输入sequence为空时 ...

  2. SpringCloud学习系列-Eureka服务注册与发现(2)

    构建 microservicecloud-eureka-7001 eureka服务注册中心Module 1.新建microservicecloud-eureka-7001 2.pom <proj ...

  3. lazarus for win32 serviceApp

    procedure TMyThread.Execute; begin //Application.EventLog.FileName:='d:\xx.txt'; //Application.Event ...

  4. 一张图解释Linux文件系统中硬链接和软链接的区别

    如图所示,硬链接与原始文件共用一个inode,但inode是不跨文件系统的(Ext3.Ext4),每个文件系统都有自己的inode列表.因此,硬链接是没办法跨文件系统的 而软链接不同,软链接相当于重新 ...

  5. Qt第三方库----QCustomPlot

    一.软件下载 下载地址:http://www.qcustomplot.com/index.php/download 这里推荐下载第一个链接的内容: 注:这里的第三方库要放在非中文目录下. 二.配置 ( ...

  6. 完美解决safari、微信浏览器下拉回弹效果。

    完美解决safari.微信浏览器下拉回弹效果,只保留局部回弹效果. CSS代码 .box{ overflow: auto; -webkit-overflow-scrolling: touch; } H ...

  7. 洛谷 P4151 BZOJ 2115 [WC2011]最大XOR和路径

    //bzoj上的题面太丑了,导致VJ的题面也很丑,于是这题用洛谷的题面 题面描述 XOR(异或)是一种二元逻辑运算,其运算结果当且仅当两个输入的布尔值不相等时才为真,否则为假. XOR 运算的真值表如 ...

  8. python-opencv学习第二章

    阈值分割(五种情况介绍) 二进制阈值化 设定一个特定的阈值量如127那么他的规则为大于等于127的像素点的灰度值设定为最大值(如8为图像灰度值最大为255) 灰度值小于127的像素点的灰度值设定为0 ...

  9. 「PKUSC 2018」真实排名

    题目链接 戳我 \(Solution\) 我们将现在所要进行的数设为\(now\) 我们分情况讨论一下 他自己不翻倍 他自己翻倍 我们首先来看看\(1\)操作 如果要满足他对排名没有影响,那么不能进行 ...

  10. tomcat的work目录的作用

    最近发现,很多网友喜欢把tomcat的work目录里的东西叫做缓存,其实那不是很恰当,work目录只是tomcat的工作目录,也就是tomcat把jsp转换为class文件的工作目录,这也正是为什么它 ...