ThreeSquares/Viliana | ThreeSquares/lowerchik | ||||
---|---|---|---|---|---|
t | t | 1 | from math import sqrt | ||
1 | seq = set(eval(input())) | 2 | inp_set = set(eval(input())) | ||
2 | maxseq = max(seq) | 3 | max_elem = max(inp_set) | ||
3 | alln = set((i * i + j * j + k * k for i in range(1, int(maxseq ** 0.5) + 1) for j in range(i, int((maxseq - i * i) ** 0.5) + 1) for k in range(j, int((maxseq - i * i - j * j) ** 0.5) + 1))) | 4 | three_squares = set((m * m + n * n + k * k for m in range(1, int(max_elem ** 0.5) + 1) for n in range(m, int((max_elem - m * m) ** 0.5) + 1) for k in range(n, int((max_elem - m * m - n * n) ** 0.5) + 1))) | ||
4 | print(len(seq.intersection(alln))) | 5 | print(len(inp_set.intersection(three_squares))) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|