链接 :



http://acm.hdu.edu.cn/showproblem.php?pid=4497

假设G不是L的约数 就不可能找到三个数。

L的全部素因子一定包括G的全部素因子 而且次方数一定大于等于G的。仅仅须要三个数 对于每个素因子的次方数 三个的最小值是G的,最大值是L的。考虑三个相应的次方数都不一样。那么当中两个是确定的 一个是G的一个是L的 剩下的一个在G和L的之间。

算上排列 总共同拥有6种。或者当中两个是一样的,那么也有6种情况。

最后能够合并计算。

//#pragma comment(linker, "/STACK:10240000,10240000")
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define mod 4294967296
#define MAX 0x3f3f3f3f
#define lson o<<1, l, m
#define rson o<<1|1, m+1, r
#define SZ(x) ((int)ans.size())
#define MAKE make_pair
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define mem(a) memset(a, 0, sizeof(a))
const double pi = acos(-1.0);
const double eps = 1e-9;
const int N = 200005;
const int M = 20005;
typedef __int64 ll;
using namespace std; ll a, b;
struct C {
ll num, cnt;
} s[N], t[N];
int T; int Ini(ll a, C* f) {
int tmp = sqrt(1.0*a + 0.5), e = 0;
for(int i = 2; i <= tmp; i++) {
if(a % i == 0) {
int k = 0;
while(a % i == 0) {
k++;
a /= i;
}
f[e].num = i;
f[e++].cnt = k;
}
}
if(a != 1) {
f[e].cnt = 1;
f[e++].num = a;
}
return e; } int main() { //freopen("in.txt","r",stdin);
cin >> T;
while(T--) {
cin >> a >> b;
if(b % a) {
puts("0");
continue;
}
mem(s);
mem(t);
int n = Ini(a, s);
int m = Ini(b, t); ll ans = 1, x;
int fr = 0;
for(int i = 0; i < m; i++) {
if(t[i].num == s[fr].num) {
x = t[i].cnt - s[fr].cnt;
fr++;
if(x) ans *= x * 6;
} else ans *= t[i].cnt * 6; }
cout << ans << endl;
}
return 0;
}

HDU 4497 GCD and LCM (分解质因数)的更多相关文章

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

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

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

  3. HDU 4497 GCD and LCM (数论)

    题意:三个数x, y, z. 给出最大公倍数g和最小公约数l.求满足条件的x,y,z有多少组. 题解:设n=g/l n=p1^n1*p2^n2...pn^nk (分解质因数 那么x = p1^x1 * ...

  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. HDU 4497 GCD and LCM(分解质因子+排列组合)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4497 题意:已知GCD(x, y, z) = G,LCM(x, y, z) = L.告诉你G.L,求满 ...

  8. HDU 4497 GCD and LCM (数学,质数分解)

    题意:给定G,L,分别是三个数最大公因数和最小公倍数,问你能找出多少对. 析:数学题,当时就想错了,就没找出规律,思路是这样的. 首先G和L有公因数,就是G,所以就可以用L除以G,然后只要找从1-(n ...

  9. hdu 4497 GCD and LCM 质因素分解+排列组合or容斥原理

    //昨天把一个i写成1了 然后挂了一下午 首先进行质因数分解g=a1^b1+a2^b2...... l=a1^b1'+a2^b2'.......,然后判断两种不可行情况:1,g的分解式中有l的分解式中 ...

随机推荐

  1. 【转】转 Linux调优方案,sysctl.conf的设置

      http://blog.sina.com.cn/s/blog_541086000100skq0.html proc/sys/net/ipv4/下各项的意义 http://blog.chinauni ...

  2. 关于Parse字符串为时间一次被坑经历

    在Java代码中发现一个bug,就是本来更新为时间的内容更新为一些奇怪的内容,比如20819这种形式,本来更新的时间都是近期不会超过一年, 为什么会出现这种情况,非常奇怪,遂调试下代码,跟踪发现要匹配 ...

  3. org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xm

    org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xm 检查jar包是否正确以及配置的xm ...

  4. 安装grub到U盘

    转自:http://hi.baidu.com/leeagle/item/6d022afc64bf7f5ec8f33743 安装GRUB到U盘 关键的几步是:3.激活/dev/sdb2 ,这步很重要,如 ...

  5. CentOS 7 系统下安装gnome图形界面

    在安装Gnome 包之前,我们需要先检查下安装源是否正常,因为我们要通过yum命令来安装gnome包, 而yum命令式通过yum 源来下载安装包的. 1.在命令行下输入下面的命令来安装 Gnome 包 ...

  6. 【Unity笔记】鼠标射线由指定层接收

    LayerMask mask = << LayerMask.NameToLayer("UI"); Ray ray = Camera.main.ScreenPointTo ...

  7. mysql初步调试

    第一次这么近距离的接触源码,有点兴奋,又有点不知所措,尼玛随便一个源文件都有几千行,你说怎么看,还有一些数不清的数据结构,函数,类等乱七八糟的东西. 我装的mysql版本是5.7.12,然后运行平台是 ...

  8. kettle7.1无法从Mongo中读取数据

    今天使用kettle读取mongo数据库时,刚开始一直无法读取数据: 在配置项中偶然选择了一个nearest然后成功了,麻蛋. 然后百度查询了下Read Reference是干嘛的,原来是读取源的模式 ...

  9. Hibernate使用createSqlQuery进行模糊查询时找不到数据

    1. 首先明确一点,使用createSqlQuery如下两种方式的占位符都可以使用,这个在官方的文档可以查到. 注意使用模糊查询时,赋值两边不可以添加单引号. Query query = sess.c ...

  10. CentOS 下 MySQL 5.7 编译安装

    MySQL5.7主要特性: 1—更好的性能:对于多核CPU.固态硬盘.锁有着更好的优化,每秒100W QPS已不再是MySQL的追求,下个版本能否上200W QPS才是吾等用户更关心的 2—更好的In ...