Problem Statement | |||||||||||||
You are given a set A of integers and a positive integer n. You must find positive integers x, y and z such that their product is as close to n as possible (minimize |n - x * y * z|), and none of them belongs to A. If there are several such triples, find the one with the smallest x. If there are still several such triples, minimize y. If there is still a tie, minimize z. You are given the elements of A as a int[] a. Return a int[] with exactly three elements: x, y and z, in this order. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | a will contain between 0 and 50 elements, inclusive. | ||||||||||||
- | Each element of a will be between 1 and 1000, inclusive. | ||||||||||||
- | All elements of a will be distinct. | ||||||||||||
- | n will be between 1 and 1000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
| |||||||||||||
5) | |||||||||||||
|