Magic Triples
Time limit2sMemory limit1024 MB
Count triples a < b < c up to n where each of the products a*b, a*c, and b*c is a perfect square.
- Level
Medium5 of 10
- Topics
- Number theory, Math, Combinatorics
- Solved
- No attempts yet
Statement
While Ian and Barley were driving down the highway, Ian suggested that Barley count magic triples to keep himself busy. A triple of positive integers , , and () is called magic if , , and are all squares of positive integers.
Help Barley solve Ian's problem by counting the magic triples.
Input
The only line contains one integer ().
Output
Print one integer, the number of magic triples.
Hint
For , the only magic triple is , , .
For , the magic triples are:
- , ,
- , ,
- , ,
- , ,
- , ,