## CCO Preparation Test 3 - Primitive Pythagorean Pairs

View as PDF

Points: 40 (partial)
Time limit: 0.6s
Memory limit: 128M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Do 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.

#### 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 .
In of the test cases, .
In of the test cases, .
In of the test cases, .
In of the test cases, .

#### 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: .

• commented on Oct. 18, 2020, 2:06 a.m.

will dmoj conjoin the subtasks together?

• commented on May 20, 2017, 3:39 a.m.

Are the tests sorted as is given in the Input specification section? I mean the first 3 tests have v_i <= 3000, second 3 have v_i <= 200000 and so on?

• commented on April 18, 2015, 1:02 p.m.

what's vi for 100% case

• commented on April 18, 2015, 1:08 p.m.

Its split into 3 parts:

In 30% of the test cases, 1≤vi≤3000.

In 30% of the test cases, 1≤vi≤200000.

In 40% of the test cases, 20000≤vi≤1000000.

• commented on April 18, 2015, 2:51 p.m.

+1, this is correct.