Sum of Three Primes
InterviewTime limit1sMemory limit256 MB
Read each odd K between 7 and 999 and print the lexicographically smallest triple of primes summing to K, or 0.
- Level
Easy3 of 10
- Topics
- Number theory, Brute force
- Solved
- No attempts yet
Problem
In number theory, the 3-primes problem is the following conjecture.
"Every odd number greater than 5 can be written as a sum of three primes. The same prime may be added more than once."
For example, , , and .
Read an odd number greater than 5 and write as a sum of three primes.
Several triples can work, so the output is fixed to one of them. Sort each triple in ascending order as and choose the lexicographically smallest one: the smallest , and among those the smallest .
Input
The first line contains the number of test cases .
Each of the next lines contains one integer . is odd and .
Output
Print one line for each test case.
If can be written as a sum of three primes, print the lexicographically smallest triple in ascending order, separated by single spaces. Otherwise print 0.