It’s quite obvious that a and b must be coprime. Now let’s prime factorize X and there will be at most 11 distinct primes since the product of the first 12 primes is greater than 1⋅1012. To find the answer we can simply distribute them between a and b with bruteforce.
Another solution is loop over all divisors d of X, check if gcd(d,dX) is 1 and minimize the answer.