hdu 1108 最小公倍数

来源:互联网 发布:python 增量拷贝文件 编辑:程序博客网 时间:2024/06/11 20:09

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

/*2011-9-10author: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);    }}