标签:
3 6 6 12 11 33 22
6 6 1 132 11 66
code:
import java.util.Scanner; public class Main3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int number = input.nextInt(); for (int i = 0;i<number;i++) { int num1 = input.nextInt(); int num2 = input.nextInt(); int result = gcd(num1,num2); System.out.println(result+" "+num1*num2/gcd(num1,num2)); } } private static int gcd(int num1, int num2) { int min = Math.min(num1,num2); int result = 0; for (int i = 1;i<=min;i++) { if (num1%i == 0 && num2%i == 0) { result = i; } } return result; } }
标签:
原文地址:http://www.cnblogs.com/airycode/p/5485282.html