ThreeSquares/OG | ThreeSquares/ilyagerelyuk | ||||
---|---|---|---|---|---|
t | 1 | from math import sqrt | t | 1 | from math import sqrt, floor |
2 | digs = set(eval(input())) | 2 | seq = set(eval(input())) | ||
3 | M = max(digs) | 3 | M = max(seq) | ||
4 | f = {i * i + j * j + k * k for i in range(1, int(sqrt(M)) + 1) for j in range(i, int(sqrt(M - i * i)) + 1) for k in range(j, int(sqrt(M - i * i - j * j) + 1))} | 4 | nums = {a * a + b * b + c * c for a in range(1, floor(sqrt(M)) + 1) for b in range(a, floor(sqrt(M - a * a)) + 1) for c in range(b, floor(sqrt(M - a * a - b * b)) + 1)} | ||
5 | print(len(f.intersection(digs))) | 5 | print(len(seq.intersection(nums))) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|