32 lines
483 B
Python
32 lines
483 B
Python
maxx = 1000000000
|
|
|
|
mul = 3 ** 0.5
|
|
n = 0
|
|
C = 0
|
|
total = 0
|
|
while 1:
|
|
n += 1
|
|
m = int((mul + 2) * n)
|
|
m += 1 - (m + n) % 2
|
|
C = 2 * (m + n) ** 2
|
|
if C > maxx: break
|
|
if abs((m - n) ** 2 - 2 * m * n) == 1:
|
|
print 4 * m * n, m ** 2 + n ** 2
|
|
total += C
|
|
|
|
n = 0
|
|
C = 0
|
|
while 1:
|
|
n += 1
|
|
m = int(mul * n)
|
|
m += 1 - (m + n) % 2
|
|
xx = m ** 2
|
|
yy = n ** 2
|
|
C = 4 * xx
|
|
if C > maxx: break
|
|
if abs(xx - 3 * yy) == 1:
|
|
print 2 * (xx - yy), xx + yy
|
|
total += C
|
|
|
|
print total
|