请问如何用Python求一个四位数,其中这个四位数正好是一个数的平方,前两位数字是相同的,后两位数字也是相同的,但与前两位数字不同,用Python求这个四位数?
# encoding: utf-8
def isidentical(i):
return i // 10 == i % 10;
if __name__ == "__main__":
for i in range(32, 100):
if (isidentical(i * i % 100) and isidentical(i * i // 100) and i * i % 100 != i * i // 100):
print(i * i)
7744
for i in range(32,101):
result = str(i**2)
if result[0] == result[1] and result[2] == result[3] and result[0] != result[3]:
result = int(result)
print(result)
else:
continue
result = []
for i in range(1, 10):
for j in range(1, 10):
if i == j:
continue
for k in range(34, 100):
if k*k == (1000*i + 100*i + 10*j + j):
result.append((i, j))
for item in result:
print(item)