阿里春招实习生笔试3.19第一题
作者:互联网
阿里春招实习生笔试3.19第一题
求大佬看看为什么程序一直输入,无输出
import math
n = int(input())
lst = list(map(int,input().split()))
lst_1 = lst[:]
a,c,f= [0]*n,[0]*n,[0]*n
for i in range(n):
while type(math.sqrt(lst[i])*10) != int:
lst[i] += 1
a[i] += 1
for i in range(n):
while type(math.sqrt(lst_1[i])*10) != int:
lst_1[i] -= 1
c[i] += 1
for i in range(n):
f[i] = min(a[i],c[i])
f.sort()
x = int(n//2)
sum = 0
for i in range(x):
sum += f[i]
print(sum)
标签:3.19,int,sum,笔试,range,lst,春招,math 来源: https://blog.csdn.net/hs563/article/details/115047404