标签:poj2429
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 9913 | Accepted: 1841 |
Description
Input
Output
Sample Input
3 60
Sample Output
12 15
Source
import java.util.Scanner; public class Main { static long gcd(long a, long b) { long c; while(b != 0) { c = a % b; a = b; b = c; } return a; } public static void main(String[] args) { Scanner cin = new Scanner(System.in); long a, b, c, i; while(cin.hasNext()) { a = cin.nextLong(); b = cin.nextLong(); c = b / a; for(i = (long)Math.sqrt(c); i > 0; --i) if(c % i == 0 && gcd(i, c / i) == 1) { System.out.println(i*a + " " + c/i*a); break; } } } }
标签:poj2429
原文地址:http://blog.csdn.net/chang_mu/article/details/41144967