hdu GCD and LCM
题意:gcd(a,b,c)=g; lcm(a,b,c)=l; 求出符合的a,b,c的所有情况有多少中。
思路:l/g=p1^x1*p2^x2*p3^x3.....; x/g=p1^a1*p2^a2*p3^a3.....; b/g=p1^b1*p2^b2*p3^b3.....; c/g=p1^c1*p2^c2*p3^c3.....;
在ai,bi,ci中至少有一个为0,至少有一个为x1,另一个的范围为0-x1;符合条件的方案数为 (x1+1)^3-(x1)^3-x1^3+(x1-1)^3; 总的情况数减去不含有0的情况和不含有x1的情况,再加上重复减去的;
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std; int t;
int g,l; int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&g,&l);
if(l%g!=)
{
printf("0\n");
}
else
{
int m=l/g;
__int64 ans=;
for(int i=; i*i<=m; i++)
{
if(m%i==)
{
int cnt=;
while(m%i==)
{
m/=i;
cnt++;
}
ans*=((cnt+)*(cnt+)*(cnt+)-cnt*cnt*cnt-cnt*cnt*cnt+(cnt-)*(cnt-)*(cnt-));
}
}
if(m>)
{
ans*=;
}
printf("%I64d\n",ans);
}
}
return ;
}
hdu GCD and LCM的更多相关文章
- hdu 4497 GCD and LCM 数学
GCD and LCM Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4 ...
- GCD and LCM HDU 4497 数论
GCD and LCM HDU 4497 数论 题意 给你三个数x,y,z的最大公约数G和最小公倍数L,问你三个数字一共有几种可能.注意123和321算两种情况. 解题思路 L代表LCM,G代表GCD ...
- HDU 4497 GCD and LCM (合数分解)
GCD and LCM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
- HDU 4497 GCD and LCM(数论+容斥原理)
GCD and LCM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
- 数论——算数基本定理 - HDU 4497 GCD and LCM
GCD and LCM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
- hdu 4497 GCD and LCM (非原创)
GCD and LCM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
- HDOJ 4497 GCD and LCM
组合数学 GCD and LCM Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) ...
- GCD 与 LCM UVA - 11388
题目链接: https://cn.vjudge.net/problem/23709/origin 本题其实有坑 数据大小太大, 2的32次方,故而一定是取巧的算法,暴力不可能过的 思路是最大公因数的倍 ...
- 简单数论总结1——gcd与lcm
并不重要的前言 最近学习了一些数论知识,但是自己都不懂自己到底学了些什么qwq,在这里把知识一并总结起来. 也不是很难的gcd和lcm 显而易见的结论: 为什么呢? 根据唯一分解定理: a和b都可被分 ...
随机推荐
- mongoDb 给表添加+ 删除字段
1 .添加一个字段. url 代表表名 , 添加字段 content. 字符串类型. db.url.update({}, {$set: {content:""}}, {multi ...
- Android 省市县 三级联动(android-wheel的使用)[转]
转载:http://blog.csdn.net/lmj623565791/article/details/23382805 今天没事跟群里面侃大山,有个哥们说道Android Wheel这个控件,以为 ...
- 《火球——UML大战需求分析》(第1章 大话UML)——1.2 结构型的UML(Structure Diagram)
说明: <火球——UML大战需求分析>是我撰写的一本关于需求分析及UML方面的书,我将会在CSDN上为大家分享前面几章的内容,总字数在几万以上,图片有数十张.欢迎你按文章的序号顺序阅读,谢 ...
- RT:How HTTP use TCP connection
In HTTP/0.9 (not used anymore), each request uses a separate TCP connection, and the end of a respon ...
- C++ | 调试 · 从汇编代码看i++和++i的区别
以int类型为例 C++编译器为++i生成的代码是 013E1375 mov eax,dword ptr [i] 013E1378 add eax, 013E137B mov dword ptr [i ...
- Ubuntu上glibc CVE-2015-7547漏洞的POC验证和修复
Ubuntu上查看Glibc版本 $ldd --version ldd (Ubuntu GLIBC 2.21-0ubuntu4) 2.21 Ubuntu上查看使用Glibc的相关程序 sudo lso ...
- SpringMVC11文件上传
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...
- Win10中英文的切换
在UAP中,涉及到中英文版本切换,在string目录下面添加资源str 读取的时候 new Windows.ApplicationModel.Resources.ResourceLoader().Ge ...
- 查看library_cache 库缓冲区的命中率
关于library cache的命中率: SQL> desc V$librarycache NAMESPACE ...
- 关于线程池ThreadPool的学习
学习重点ThreadPool.SetMinThreads(out workerThreads, out completionPortThreads).这是整个线程池的关键. 而ThreadPool. ...