题意: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的更多相关文章

  1. 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 ...

  2. GCD and LCM HDU 4497 数论

    GCD and LCM HDU 4497 数论 题意 给你三个数x,y,z的最大公约数G和最小公倍数L,问你三个数字一共有几种可能.注意123和321算两种情况. 解题思路 L代表LCM,G代表GCD ...

  3. HDU 4497 GCD and LCM (合数分解)

    GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  4. HDU 4497 GCD and LCM(数论+容斥原理)

    GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  5. 数论——算数基本定理 - HDU 4497 GCD and LCM

    GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  6. hdu 4497 GCD and LCM (非原创)

    GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  7. HDOJ 4497 GCD and LCM

    组合数学 GCD and LCM Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) ...

  8. GCD 与 LCM UVA - 11388

    题目链接: https://cn.vjudge.net/problem/23709/origin 本题其实有坑 数据大小太大, 2的32次方,故而一定是取巧的算法,暴力不可能过的 思路是最大公因数的倍 ...

  9. 简单数论总结1——gcd与lcm

    并不重要的前言 最近学习了一些数论知识,但是自己都不懂自己到底学了些什么qwq,在这里把知识一并总结起来. 也不是很难的gcd和lcm 显而易见的结论: 为什么呢? 根据唯一分解定理: a和b都可被分 ...

随机推荐

  1. Solr使用solr4J操作索引库

    Solrj是Solr搜索服务器的一个比较基础的客户端工具,可以非常方便地与Solr搜索服务器进行交互.最基本的功能就是管理Solr索引,包括添加.更新.删除和查询等.对于一些比较基础的应用,用Solj ...

  2. CentOS 搭建 FastDFS-5.0.5集群

    转http://www.open-open.com/lib/view/open1435468300700.html 第一步,确定目标: Tracker  192.168.224.20:22122  C ...

  3. IE6和IE7下绝对定位position:absolute和margin的冲突问题解决

    绝对定位的Position:absoulte的元素,会让相邻的兄弟元素的margin-top失效.而如果去掉了兄弟元素的高度又会正常. <div id="layer1" st ...

  4. [转] C++临时变量的生命周期

    http://www.cnblogs.com/catch/p/3251937.html C++中的临时变量指的是那些由编译器根据需要在栈上产生的,没有名字的变量. 主要的用途主要有两类: 1) 函数的 ...

  5. 浅谈Android架构之MVP,MVVM

    概述 MVP(Model-View-Presenter)是传统MVC(Model-View-Controller)在Android开发上的一种变种.进化模式.主要用来隔离UI.UI逻辑和业务逻辑.数据 ...

  6. 2015 南阳ccpc The Battle of Chibi (uestc 1217)

    题意:给定一个序列,找出长度为m的严格递增序列的个数. 思路:用dp[i][j]表示长度为i的序列以下标j结尾的总个数.三层for循环肯定超时,首先离散化,离散化之后就可以用树状数组来优化,快速查找下 ...

  7. Python之路,Day14 - It's time for Django

    Python之路,Day14 - It's time for Django   本节内容 Django流程介绍 Django url Django view Django models Django ...

  8. python字符串replace()方法

    python字符串replace()方法 >>> help(str.replace)Help on method_descriptor:replace(...)    S.repla ...

  9. C#中的操作数据库的SQLHelper类

    using System; using System.Collections.Generic; using System.Configuration; using System.Data; using ...

  10. 使用EF 的简单的增删改查

    using DAL; using Model; using System; using System.Collections.Generic; using System.Linq; using Sys ...