#K51147. Prime Sum Triple Representation

    ID: 29023 Type: Default 1000ms 256MiB

Prime Sum Triple Representation

Prime Sum Triple Representation

Given a positive integer (n), determine whether it can be represented as the sum of three prime numbers. If such a representation exists, output one valid combination of three primes in non-decreasing order that sum up to (n). Otherwise, output -1.

The three primes need not be distinct. You are to read the input from standard input and write the output to standard output. Note that all numbers involved and the sum must satisfy the condition that each number is a prime number. The representation must be computed using an algorithm that checks for prime numbers and then finds two numbers, calculates the third and verifies its primality.

inputFormat

The input consists of a single integer (n) (where (4 \le n \le 30000)) provided via standard input.

outputFormat

If there exists a valid triple of prime numbers (p_1), (p_2), (p_3) such that (p_1 + p_2 + p_3 = n) and (p_1 \le p_2 \le p_3), output these three numbers separated by spaces. Otherwise, output -1.## sample

30
2 5 23

</p>