Pra*_*ngh 4 int type-conversion factors python-3.x long-integer
temp=input()
l=list(map(int,temp.split()))
count=0
for i in range (1,min(l[0],l[1])+1):
if l[0]%i==0 and l[1]%i==0:
count+=1
print (count)
Run Code Online (Sandbox Code Playgroud)
上面的代码需要 2 个或更多的数字并找到公因数的数量。这些数字的范围是 1 到 10**12。
如何处理这段代码中的 int 和 long 数据类型?请帮忙。
与 Python 2 不同,Python 3 不区分int和long(long从 Python 3 中消失了)。它只是一个整数,甚至可以长于 64 位。
来自 Python 3 文档