优雅的点(2017网易校招)--python版本
题目分析见我的c++版本:https://blog.****.net/newandbetter/article/details/80341512
import math
z = float(input())
r = math.sqrt(z)
count = 0
if(r == int(r)):
count = count + 4
count = count + 4
for x in range(1,math.ceil(r)): #为什么要上取整?因为我想要从1循环到r,如果r=5.5,那么int(5.5) = 5,x 就是0 1 2 3 4,取 #不到5,上取整才可以取到5,c++为什么可以,因为for(int x=1; i <r;x++)r
#是实数,在python中不可用实数在range中
y = math.sqrt(z - x*x)
if(y == int(y)):
count = count + 4
y = math.sqrt(z - x*x)
if(y == int(y)):
count = count + 4
print (count)