解题思路:
注意事项:
参考代码:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int a=in.nextInt();
int b=in.nextInt();
int i,c=a*b;
for(i=a;i>=1;i--)
if(a%i==0&&b%i==0)break;
System.out.print(i);
if(a<b)
{
int r=0;
r=a;a=b;b=r;
}
while(true)
{
int r=a%b;
if(r==0){
System.out.print(" "+c/b);
break;
}else
{
a=b;
b=r;
}
}
}
}
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int a=in.nextInt();
int b=in.nextInt();
int i,c=a*b;
for(i=a;i>=1;i--)
if(a%i==0&&b%i==0)break;
System.out.print(i);
System.out.print(" "+c/i);
}
}
*/
0.0分
0 人评分