Goldbach Triple
Time limit2sMemory limit512 MB
For each odd N up to one million, count the unordered ways to write N as a sum of three primes.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Prefix sum, Brute force
- Solved
- No attempts yet
Problem
- Goldbach's conjecture: every even number greater than 2 can be written as the sum of two primes.
- Goldbach's weak conjecture: every odd number greater than 5 can be written as the sum of three primes.
A way of writing an odd number as the sum of three primes is called a Goldbach triple. Given an odd number , count the Goldbach triples of . Triples that differ only in the order of the three primes are the same triple.
Input
The first line gives the number of test cases (). Each test case occupies one line and contains an integer that is odd and satisfies .
Output
For each test case, print the number of Goldbach triples.