#C4260. Find Pair with Given Product
Find Pair with Given Product
Find Pair with Given Product
You are given an array A of n distinct integers and a target integer X. Your task is to find two distinct numbers from the array such that their product equals \(X\). Formally, if the two numbers are \(a\) and \(b\), then they must satisfy:
\(a \times b = X\)
If such a pair exists, print the two numbers (in any order) separated by a space. If no such pair exists, print -1
.
Note: The input is read from stdin and the output should be written to stdout.
inputFormat
The first line contains two integers n
and X
, where n
is the number of elements in the array and X
is the target product. The second line contains n
distinct integers separated by spaces.
outputFormat
If there exists a pair of numbers whose product equals X
, output the two numbers separated by a space. If no such pair exists, output -1
.## sample
5 8
1 2 4 5 3
4 2