Problem p02995 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
#最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

c_div_a = (a-1) // c
c_div_all = b // c

d_div_a = (a-1) // d
d_div_all = b // d


cd_div_a = (a-1) // int( lcm(c, d) )
# print("cd_div_a", cd_div_a)
cd_div_all = b // int( lcm(c, d) )
# print("cd_div_all", cd_div_all)


div_a = c_div_a + d_div_a - cd_div_a
div_all = c_div_all + d_div_all - cd_div_all

print( (b - (a-1)) - (div_all - div_a) )

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

c_div_a = (a-1) // c
# print("c_div_a:", c_div_a)
c_div_all = b // c
# print("c_div_all:", c_div_all)

# print("---")

d_div_a = (a-1) // d
# print("d_div_a:", d_div_a)
d_div_all = b // d
# print("d_div_all:", d_div_all)

# print("---")

cd_div_a = (a-1) // int( (c*d) / math.gcd(c, d) )
# print("cd_div_a:", cd_div_a)
cd_div_all = b // int( (c*d) / math.gcd(c, d) )
# print("cd_div_all:", cd_div_all)

# print("---")

div_a = c_div_a + d_div_a - cd_div_a
# print("div_a:", div_a)
div_all = c_div_all + d_div_all - cd_div_all
# print("div_all:", div_all)

print( (b - (a-1)) - (div_all - div_a) )

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

c_div_a = (a-1) // c
# print("c_div_a:", c_div_a)
c_div_all = b // c
# print("c_div_all:", c_div_all)

# print("---")

d_div_a = (a-1) // d
# print("d_div_a:", d_div_a)
d_div_all = b // d
# print("d_div_all:", d_div_all)

# print("---")

cd_div_a = (a-1) // int( (c*d) / math.gcd(c, d) )
# print("cd_div_a:", cd_div_a)
cd_div_all = b // int( (c*d) / math.gcd(c, d) )
# print("cd_div_all:", cd_div_all)

# print("---")

div_a = c_div_a + d_div_a - cd_div_a
# print("div_a:", div_a)
div_all = c_div_all + d_div_all - cd_div_all
# print("div_all:", div_all)

print( (b - (a-1)) - (div_all - div_a) )

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

c_div_a = (a-1) // c
# print("c_div_a:", c_div_a)
c_div_all = b // c
# print("c_div_all:", c_div_all)

# print("---")

d_div_a = (a-1) // d
# print("d_div_a:", d_div_a)
d_div_all = b // d
# print("d_div_all:", d_div_all)

# print("---")

cd_div_a = (a-1) // int( (c*d) / math.gcd(c, d) )
# print("cd_div_a:", cd_div_a)
cd_div_all = b // int( (c*d) / math.gcd(c, d) )
# print("cd_div_all:", cd_div_all)

# print("---")

div_a = c_div_a + d_div_a - cd_div_a
# print("div_a:", div_a)
div_all = c_div_all + d_div_all - cd_div_all
# print("div_all:", div_all)

print( (b - (a-1)) - (div_all - div_a) )

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

c_div_a = (a-1) // c
# print("c_div_a:", c_div_a)
c_div_all = b // c
# print("c_div_all:", c_div_all)

# print("---")

d_div_a = (a-1) // d
# print("d_div_a:", d_div_a)
d_div_all = b // d
# print("d_div_all:", d_div_all)

# print("---")

cd_div_a = (a-1) // int( (c*d) / math.gcd(c, d) )
# print("cd_div_a:", cd_div_a)
cd_div_all = b // int( (c*d) / math.gcd(c, d) )
# print("cd_div_all:", cd_div_all)

# print("---")

div_a = c_div_a + d_div_a - cd_div_a
# print("div_a:", div_a)
div_all = c_div_all + d_div_all - cd_div_all
# print("div_all:", div_all)

print( (b - (a-1)) - (div_all - div_a) )