Problem Description
输入两个正整数,求它们的最大公约数与最小公倍数。
Input
输入两个正整数,两个整数之间用空格分开。
数据保证在 int 范围内。
Output
第一行输出最大公约数;
第二行输出最小公倍数。
答案保证在 int 范围内。
Sample Input
64 48
Sample Output
16 192
import java.util.Scanner;
class gongyue {
int x, y;
public gongyue(int x, int y){
this.x = x;
this.y = y;
}
public int gy(){
if(x>y){
int t=x;x=y;y=t;
}
while(x!=0){
int t = y%x;
y = x;
x = t;
}
return y;
}
}
class gongbei {
int x, y;
public gongbei(int x, int y){
this.x = x;
this.y = y;
}
public int gb(){
int a=x, b=y;
gongyue rect = new gongyue(a, b);
int g = rect.gy();
return x*y/g;
}
}
public class Main {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int x = reader.nextInt();
int y = reader.nextInt();
gongyue m = new gongyue(x, y);
gongbei n = new gongbei(x, y);
int a = m.gy();
int b = n.gb();
System.out.println(a+"\n"+b);
}
}