D - Disjoint Set of Common Divisors
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的更多相关文章
- Common Divisors CodeForces - 182D || kmp最小循环节
Common Divisors CodeForces - 182D 思路:用kmp求next数组的方法求出两个字符串的最小循环节长度(http://blog.csdn.net/acraz/articl ...
- CF #579 (Div. 3) C.Common Divisors
C.Common Divisors time limit per test2 seconds memory limit per test256 megabytes inputstandard inpu ...
- B - Common Divisors (codeforces)数论算法基本定理,唯一分解定理模板
You are given an array aa consisting of nn integers. Your task is to say the number of such positive ...
- [gcd]Codeforces Common Divisors
Common Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #579 (Div. 3) B Equal Rectangles、C. Common Divisors
B Equal Rectangles 题意: 给你4*n个数,让你判断能不能用这个4*n个数为边凑成n个矩形,使的每个矩形面积相等 题解: 原本是想着用二分来找出来那个最终的面积,但是仔细想一想,那个 ...
- <Sicily>Greatest Common Divisors
一.题目描述 A common divisor for two positive numbers is a number which both numbers are divisible by. It ...
- Codeforces182D - Common Divisors(KMP)
题目大意 如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S1和S2,求它们的公共因子个数 题解 如果它们有公共因子,那么显然它们的最小公共因子肯定是 ...
- Codeforces Round #117 (Div. 2) D.Common Divisors(KMP最小循环节)
http://codeforces.com/problemset/problem/182/D 题意:如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S ...
- Common Divisors CodeForces - 1203C
题意: 给你n个数,让你找出来公因子有多少个.公因子:对于这n个数,都能被这个公因子整除 题解: 只需要找出来这n个数的最大公因子x,然后找出来有多少不同数能把x给整.(因为我们可以保证x可以把这n个 ...
随机推荐
- 9. ClustrixDB主从复制
一.在线添加从库 主集群: 10.1.1.23:5306 从集群: 10.1.3.88:5306 主库开启binlog MySQL [(none)]> CREATE BINLOG 'clustr ...
- Memcached在Asp.net下的应用
Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度.Memcached ...
- oracle 7.4安装nvidia驱动
2019-8-28 参考网页: 如何在k8s集群中安装nvidia.cuda并使用GPU进行训练 https://blog.csdn.net/u013042928/article/details/78 ...
- js dom 添加类
var sheng = document.getElementById("sheng"); ; sheng.onclick = function() { if(this.paren ...
- MySQL_DQL操作
DQL(Data Query Language)简单的来说就是数据的查询语言. 1.最简单的查询(显示表中的所有信息) 语法: select * from 表名; 2.普通查询 语法: select ...
- 记一次CTF实验吧的代码审计
0X01 0X01 Burp抓包找到hint 访问地址看源码 <?php $info = ""; $req = []; $flag="xxxxxxxxxx" ...
- Flask基础总结
Flask 基础总结 .Flask优点: 拥有强大的第三方组件小而精非常全面,不足就是更新太快 .Flask中的三剑客: HTTPRespone redierct render_template .F ...
- Linux_系统进程管理
目录 目录 进程管理 进程管理的指令 查看进程ps指令 pgreppidof指令查pid lsof查看系统中的进程 nice指令修改进程的nice值 kill指令结束进程 top系统进程管理器任务管理 ...
- tomcat7源码包编译安装
tomcat/:作用解析jsp程序.先安装jdk容器.1.下载jdk, wget http://download.oracle.com/otn- pub/java/jdk/8u131- b11/d54 ...
- 阶段3 1.Mybatis_03.自定义Mybatis框架_4.自定义mybatis的编码-解析XML的工具类介绍
导入xml操作的类和用到的相关包 创建util包,然后把提供好的XMLConfigBuilder.java文件复制3过来 复制过来,里面用到了很多dom4j的东西 打开pom.xml 输入depend ...