【ACM】最小公倍数
2013-12-10 21:51
169 查看
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=2§ionid=1&problemid=1
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int a,b,c,m,n; while( scanf( "%d%d" , &n , &m ) != EOF ) { if( n > m) { a = n ; b = m ; } else { a = m ; b = n; } while ( b != 0 ) { /* 最小公倍数 = m*n/GCD(m,n) */ c = a % b ; a = b ; b = c ; } printf( "%d\n" , ( m * n ) /a ); } return 0; }
相关文章推荐
- ACM内部函数--数学问题--最大公约数最小公倍数
- 杭电ACM——HDU-1108最小公倍数
- 山东理工大学ACM平台题答案关于C语言 1181 C语言实验——最小公倍数和最大公约数
- 山东理工大学ACM平台题答案关于C语言 1181 C语言实验——最小公倍数和最大公约数
- acm 1108 求两个数的最小公倍数
- ACM数论之旅3---最大公约数gcd和最小公倍数lcm(苦海无边,回头是岸( ̄∀ ̄))
- 杭电ACM 最小公倍数
- 【HDU6195 2017 ACM ICPC Asia Regional Shenyang Online B】【水题 匹配】cable cable cable M个格子任选K个放K个物品的最小连边匹配
- 关于求连续区间的最小公倍数
- 01-求最大公约数与最小公倍数
- Least Common Multiple(最小公倍数)
- hdu 1713求分数的最小公倍数
- 递归实现最大公约数最小公倍数
- 蓝桥杯 ALGO-2:最大最小公倍数
- POJ 3101 Astronomy (挖坑待学Java……最小公倍数---大数表示)
- [莫比乌斯反演 积性函数前缀和] 51Nod 1190 最小公倍数之和 V2
- c++穷举法求最大公约数和最小公倍数的实例中如何调用max和min函数
- 求最大公约数和最小公倍数的最简单 高效的算法
- Java 求两个数最小公倍数
- hdu 1019Least Common Multiple(最小公倍数)