For each T, count the triangles whose three sides are prime numbers summing to T, counting only congruence classes.
Medium5MathNumber theoryNo attempts yetTime limit8sMemory limit512 MBThe space hunter Ken Marineblue traveled the universe looking for the space coconut crab. The space coconut crab is the largest crustacean known. Its body is more than 400 meters long and its leg span is no shorter than 1000 meters. Many people have reported seeing one, but nobody has captured one yet.
After years of research Ken found out that the crab moves between space and hyperspace by phase drive. Humans cannot travel to hyperspace, so the crab has to be caught in space. The crab keeps still in hyperspace while it charges the energy the phase drive needs, and right after it warps out it moves very slowly. Ken decided to strike at that moment.
The only quantity Ken can measure is the time the crab spent charging energy in hyperspace. CANEL, the artificial intelligence installed on his spaceship Weapon Breaker, analyzed the accumulated data and found that the crab always warps out near the center of a triangle that satisfies all of the following conditions.
Given the side lengths, CANEL can tell which three planets they are, but more than one triangle may satisfy the conditions. For each T, count the triangles that satisfy the conditions. Three primes form a triangle only when the two shorter side lengths add up to more than the longest side length.
The input consists of several datasets. Each dataset is a line with a single positive integer T (1≤T≤30000).
The last line holds a single 0 and is not a dataset.
For each dataset, print the number of triangles, one per line. Two triangles count as different only when they are not congruent.