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. IDEA 2018.1可用License服务(持续更新)

    1. http://idea.congm.in 2.http://idea.toocruel.net

  2. 游标定位:Cursor类

    关于 Cursor Cursor 是每行的集合. 使用 moveToFirst() 定位第一行. 你必须知道每一列的名称. 你必须知道每一列的数据类型. Cursor 是一个随机的数据源. 所有的数据 ...

  3. 花式求LCA

    设树上有两点x.y,要求他们的lca(最近公共祖先) 1.倍增求LCA: 先预处理出树上每个点的向上2^k的祖先. 再看x.y:先把深度深的倍增跳到和深度浅的一样的深度,判断是否在同一点:是,该点即为 ...

  4. 使用FunctionalInterface提供工厂方法

    1. 首先提供User类 public class User { private int id; private String name; public User(int id, String nam ...

  5. CSS注

    1.css3内容上下左右居中 .box { display:-moz-box; -moz-box-pack:center; -moz-box-align:center; display:-webkit ...

  6. hdu5988(费用流,对数相乘做加法)

    题意:一个网络流的图,有n个点,从1~n,然后m条边,每个点有两个值,一个是人的数量si一个是饭的数量bi.每条m边有容量ci,还有走上去可能踩断电线的概率pi(第一次踩上去没有事,之后都要p概率). ...

  7. zabbix监控惠普打印机

    http://www.ttlsa.com/zabbix/zabbix-monitor-hp-printer/

  8. bind标签_databaseId标签,_parameter标签的使用

    1.在接口写方法 public List<Employee> getEmpsTestInnerParameter(Employee employee); 2在映射文件中进行配置 <s ...

  9. 洛谷P5022&P5049 旅行(及其数据加强版)

    旅行(不是加强版) 加强版 加强版数据范围: 我们注意到 也就是说要么是个树,要么是个基环树 60pts 这60分是个树,可以简单的贪心想到每次都走子树中编号最小的那个,并且把1作为根 dfs练手题 ...

  10. 使用System.ComponentModel.DataAnnotations验证字段数据正确性

    在.NET MVC 中,当页面提交model到Action的时候,自动填充ModelState.使用ModelState.IsValid进行方便快捷的数据验证,其验证也是调用命名空间System.Co ...