This time, if you know the standard input method, you can do it. There is also a device to find the divisor.
C19
python
input_line = input()
def divs(x):
return [d for d in range(1, x + 1) if x % d == 0]
for i in range(int(input_line)):
input_int = input()
result = divs(int(input_int))
N = result[-1]
S = sum(result[0:-1])
score = N-S
if score == 0:
print("perfect")
elif score == 1:
print("nearly")
else:
print("neither")
Recommended Posts