Today, Osama gave Fadi an integer X X X, and Fadi was wondering about the minimum possible value of m a x ( a , b ) max(a,b) max(a,b) such that L C M ( a , b ) LCM(a,b) LCM(a,b) equals X X X. Both a and b should be positive integers.
L C M ( a , b ) LCM(a,b) LCM(a,b) is the smallest positive integer that is divisible by both a a a and b b b. For example, L C M ( 6 , 8 ) = 24 , L C M ( 4 , 12 ) = 12 , L C M ( 2 , 3 ) = 6 LCM(6,8)=24, LCM(4,12)=12, LCM(2,3)=6 LCM(6,8)=24,LCM(4,12)=12,LCM(2,3)=6.
Of course, Fadi immediately knew the answer. Can you be just like Fadi and find any such pair?
Input
The first and only line contains an integer X ( 1 ≤ X ≤ 1 0 12 ) X (1≤X≤10^{12}) X(1≤X≤1012).
Output
Print two positive integers, a a a and b b b, such that the value of m a x ( a , b ) max(a,b) max(a,b) is minimum possible and L C M ( a , b ) LCM(a,b) LCM(a,b) equals X X X. If there are several possible such pairs, you can print any.
Examples
input
2
output
1 2
input
6
output
2 3
input
4
output
1 4
input
1
output
1 1
思路
l c m ( a , b ) = a ∗ b / g c d ( a , b ) = x lcm(a,b)=a*b/gcd(a,b)=x lcm(a,b)=a∗b/gcd(a,b)=x
要让 m a x ( a , b ) max(a,b) max(a,b)最小
a ∗ b = x a*b=x a∗b=x && g c d ( a , b ) = 1 gcd(a,b)=1 gcd(a,b)=1
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll X,ans=1e12+10,ansa,ansb;
int main() {
scanf("%lld", &X);
for (ll i = 1; i * i <= X; i++) {
if (X % i == 0) {
ll a = i, b = X / i;
if (__gcd(a, b) == 1 && max(a, b) < ans) {
ansa = a;
ansb = b;
ans = max(a, b);
}
}
}
printf("%lld %lld\n", ansa, ansb);
return 0;
}