#C10356. Triplet Product Existence
Triplet Product Existence
Triplet Product Existence
You are given an array of integers and a target value. Your task is to determine whether there exist three distinct indices i, j, and k such that the product of the elements at these indices is equal to the target value.
Formally, given an array \(a\) of length \(n\) and an integer \(T\) (the target), you need to check if there exist indices \(i, j, k\) (with \(i \neq j \neq k\)) satisfying:
[ a_i \times a_j \times a_k = T ]
Print "Yes" if such a triplet exists or "No" otherwise. Note that the array may contain negative numbers and zeros, and these edge cases should be handled appropriately.
inputFormat
The input is given from stdin and it consists of:
- A single integer \(n\), the number of elements in the array.
- \(n\) space-separated integers representing the elements of the array.
- An integer \(T\) representing the target product.
All values are separated by spaces and/or newlines.
outputFormat
Output a single line to stdout containing "Yes" if there exist three distinct indices such that the product of the corresponding elements equals the target \(T\), and "No" otherwise.
## sample5 1 2 3 4 5 6
Yes