HDOJ 4497 GCD and LCM
组合数学
GCD and LCM
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 451 Accepted Submission(s): 216
Note, gcd(x, y, z) means the greatest common divisor of x, y and z, while lcm(x, y, z) means the least common multiple of x, y and z.
Note 2, (1, 2, 3) and (1, 3, 2) are two different solutions.
The next T lines, each contains two positive 32-bit signed integers, G and L.
It’s guaranteed that each answer will fit in a 32-bit signed integer.
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int main()
{
int t,L,G;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&G,&L);
if(L%G!=)
{
puts("");
continue;
}
int sk=L/G;
int pp=,ans=,cnt;
while(sk!=)
{
cnt=;
while(sk%pp==)
{
cnt++;
sk/=pp;
}
pp++;
if(cnt!=)
{
ans*=cnt*;
}
}
printf("%d\n",ans);
}
return ;
}
HDOJ 4497 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 ...
- 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 ...
- 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,求满 ...
- 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 * ...
- hdu 4497 GCD and LCM(2013 ACM-ICPC吉林通化全国邀请赛——题目重现)
质分解 + 简单计数.当时去比赛的时候太年轻了...这道题都没敢想.现在回过头来做了一下,发现挺简单的,当时没做这道题真是挺遗憾的.这道题就是把lcm / gcd 质分解,统计每个质因子的个数,然后 ...
- HDU 4497 GCD and LCM 素因子分解+ gcd 和 lcm
题意: 给两个数,lll 和 ggg,为x , y , z,的最小公倍数和最大公约数,求出x , y , z 的值有多少种可能性 思路: 将x , y , z进行素因子分解 素因子的幂次 x a1 a ...
随机推荐
- C#获取外网IP
思路是通过WebRequest连接一些网上提供IP查询服务的网站,下载到含有你的IP的网页,然后用正则表达式提取出IP来 class Program { static void Main(string ...
- Visual Studio原生开发的10个调试技巧
这篇文章只介绍了一些有关Visual Studio的基本调试技巧,但是还有其他一些同样有用的技巧.我整理了一些Visual Studio(至少在VS 2008下)原生开发的调试技巧.(如果你是工作在托 ...
- hdu 1233 - 还是畅通工程(MST)
还是畅通工程 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- CSS--结构和层叠
选择器的特殊性 特殊性值表述为4个部分,如0,0,0,0.具体特殊性如下所示: 举例说明一下: 通配符选择器的特殊性 通配符选择器其特殊性为0,0,0,0 !important重要性 大家都知道内联样 ...
- iOS - CAEmitterLayer 学习笔记一
其他参考博客: http://my.oschina.net/u/2340880/blog/485095 http://www.cnblogs.com/YouXianMing/p/3785876.htm ...
- JQuery 和JavaScript的区别
Google提供的jquery包: http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js jQuery官方的jquery包: ...
- WinForm------TreeList修改节点图标和按钮样式
转载: https://documentation.devexpress.com/#WindowsForms/DevExpressXtraTreeListTreeList_CustomDrawNode ...
- centos设置编码
CentOS6.5解决中文乱码与设置字符集 Windows的默认编码为GBK,Linux的默认编码为UTF-8.在Windows下编辑的中文,在Linux下显示为乱码.为了解决此问题,修改Linux的 ...
- js字符串RTrim方法(right trim)
String.prototype.RTrim = function (c) { if (!c) { c = ' '; } var reg = new RegExp('([' + c + ']*$)', ...
- Nginx+PHP-fpm高负载优化及压力测试方法
Nginx+PHP-fpm组合,以内存占用小,负载能力强壮的特点,成为小内存VPS建站的首选组合.我们一起来探讨一下nginx+php-fpm高负载的优化方法. 先来看看nginx配置参数的优化.ng ...