您的位置:首页 > 其它

hdu 1108 最小公倍数

2011-09-10 19:29 369 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1108

/*
2011-9-10
author:BearFly1990
*/
package acm.hdu.tests;

import java.io.BufferedInputStream;
import java.util.Scanner;

public class HDU_1108 {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedInputStream(System.in));
int ina , inb;
while(in.hasNext()){
ina = in.nextInt();
inb = in.nextInt();
System.out.println(lcm(ina,inb));

}
}
public static int lcm(int a ,int b){
if(a < b){
int temp = a;
a = b;
b = temp;
}
return a * b /gcd(a,b);
}
public static int gcd(int a , int b){
if(b == 0)return a ;
return gcd(b,a%b);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: