##### Canadian Computing Competition: 2019 Stage 1, Senior #2

For various given positive integers , find two primes, and such that is the average (mean) of and . That is, should be equal to .

Recall that a *prime number* is an integer which is only divisible by and . For example, , , , , are the first few primes, and , , , are not prime numbers.

#### Input Specification

The first line of input is the number , which is the number of test cases. Each of the next lines contain one integer .

For 6 of the available 15 marks, all .

#### Output Specification

The output will consist of lines. The line of output will contain two integers, and , separated by one space. It should be the case that and that and are prime numbers.

If there are more than one possible and for a particular , output any such pair. The order of the pair and does not matter.

It will be the case that there will always be at least one set of values and for any given .

#### Sample Input 1

```
4
8
4
7
21
```

#### Sample Output 1

```
3 13
5 3
7 7
13 29
```

#### Explanation of Possible Output for Sample Input

Notice that:

It is interesting to note, that we can also write

and so any of these pairs could have also been used in output. There is no pairs of primes other than and which average to the value of .

##### Footnote

You may have heard about *Goldbach's conjecture*, which states that every even integer greater than 2 can be expressed as the sum of two prime numbers. There is no known proof, yet, so if you want to be famous, prove that conjecture (after you finish the CCC).

This problem can be used to help verify that conjecture, since every even integer can be written as , and your task is to find two primes and such that .

## Comments

Is this question possible in python ?

Yes https://dmoj.ca/problem/ccc19s2/rank/?language=PY2&language=PY3&language=PYPY&language=PYPY3

This comment is hidden due to too much negative feedback. Click here to view it.

Any tips to pass the second batch of test cases? Appears to be a case I missed in my code where I run into index out of bounds for the first test case of the second batch. The first batch was successful. (Written in Java).

This comment is hidden due to too much negative feedback. Click here to view it.

39 is not a prime

Your output is most likely clipped so you will not be able to see the full output. Meaning that the output that was clipped might be correct, but the rest of your output may contain errors. For CCC problems, you can find the test-data on the official CCC website.

This comment is hidden due to too much negative feedback. Click here to view it.

Is there a reason I am getting

`RTE`

"floating point error" in c although I never do any weird arithmetic and never divide or mod by 0?This comment is hidden due to too much negative feedback. Click here to view it.

It is possible to pass by precomputing primes, and it is also possible to pass by not precomputing primes. Both methods pass within the time limit.

So CCC limit its time for solving problem to 1sec already? I thought previously, for all unspecifed questions, they limit it to 5 sec?

During the CCC, the problem was specifically limited to 1 second.

I see! Thank you for your reply!

My solution passed on the CCC but not here?

Python is slow. Try submitting in PyPy.

PyPy MLE's