CCO Preparation Test 3 P1 - Primitive Pythagorean Pairs
View as PDFDo you know the Pythagorean theorem? Definitely yes. Do you know Pythagorean triples? Maybe not. Do you know primitive Pythagorean pairs? Definitely not, because Bruce has not defined it yet! Let's start from Pythagorean triples. A Pythagorean triple consists of three positive integers , 
, and 
, such that 
. If 
 and 
 are also coprime, the pair 
 is named a primitive Pythagorean pair, like 
. Bruce will tell you how to generate primitive Pythagorean pairs. Given two positive integers 
 and 
 
, if 
 and 
 are coprime and 
 is odd, a primitive Pythagorean pair 
 can be calculated by 
 and 
. There are an infinite number of primitive Pythagorean pairs.
Now Bruce has  cards, each of which has a positive integer 
 
. He wants to pick up a number of cards so that there are no primitive Pythagorean pairs among the selected cards. Could you please help Bruce to get the total number of different selections? Two selections are different if and only if one card is in one selection, but is not in the other selection. Bruce has to select at least one card in each selection.
Constraints
For all subtasks:
Subtask 1 [30%]
Subtask 2 [30%]
Subtask 3 [40%]
Input Specification
The first line of input will consist of one integer, , the number of cards Bruce has.
The second line of input will consist of  positive integers 
, where 
 is the value of card 
 
.
Output Specification
Output one integer, the number of different selections modulo .
Sample Input
4
5 12 35 5
Sample Output
8
Explanation of Output for Sample Input
There are two primitive Pythagorean pairs  and 
. So, there are 
 different selections: 
.
Comments