#P3213. [HNOI2011] 勾股定理
[HNOI2011] 勾股定理
Description
Momo has been studying the Pythagorean Theorem. For two positive integers and , if there exists a positive integer such that , and and are coprime, then is called a primitive Pythagorean pair.
One day, Momo obtained sticks, each with a positive integer length. She plans to select some of these sticks to play a puzzle game. To make the pattern look artfully messy, she wants the lengths of any two selected sticks to not form a primitive Pythagorean pair. Now, Momo wants to know how many selection schemes meet the requirement. Since the answer may be large, you only need to output the result modulo .
Input Format
The first line contains a positive integer , the number of sticks.
The second line contains space-separated positive integers , where for , denotes the length of the -th stick.
The testdata guarantees that:
- For of the testdata, for all , .
- For another of the testdata, for all , .
- For the remaining of the testdata, for all , .
- For of the testdata, .
Output Format
Output a single non-negative integer, the number of valid selection schemes modulo .
4
5 12 35 5
8
Hint
Sample explanation: and are primitive Pythagorean pairs, so there are valid selection schemes, namely:
$\{5\}, \{12\}, \{35\}, \{5\}, \{5,35\}, \{35,5\}, \{5,5\}, \{5,35,5\}$.
Translated by ChatGPT 5
京公网安备 11011102002149号