使用 python语言一直出错求求佬帮忙看看

P1029 [NOIP2001 普及组] 最大公约数和最小公倍数问题

weihaoyei012 @ 2025-01-06 18:01:49

def gcd(a,b):
    if a < b:
        a,b = b,a
    while b > 0:
        a,b = b,a%b
    return a

def Answer(x,y):
    k = 0
    y_01 = int((x * y)**0.5) + 1
    for j in range(x,y_01):
       if (x * y) % j == 0 and gcd(j,(x * y)// j) == x:
            k += 2
    return k

z = input("请输入两个整数: ")
z_1 = z.split(" ")
x = int(z_1[0])
y = int(z_1[1])
print(Answer(x,y))

by yyyhy @ 2025-01-06 18:18:36

@weihaoyei012

为什么要加这句中文

z = input("请输入两个整数: ")


by weihaoyei012 @ 2025-01-06 18:31:17

@yyyhy会影响它的输入吗(哭


by THU_ACMER @ 2025-01-06 18:36:48

input里面不要写


by THU_ACMER @ 2025-01-06 18:37:32

@weihaoyei012会


by weihaoyei012 @ 2025-01-06 18:43:55

@THU_ACMER@THU_ACMER 问题解决了,谢谢你!


|