Problem: You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.

Submission attempts (in order):
i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]
 
n = 0
m = 0
nm = 0
 
 
for i in range(a,b):
  if i % c == 0:
    n =+ 1
    
    
for j in range(a,b):
  if j % d == 0:
    m =+ 1
 
    
for k in range(a,b):
  if (k % c == 0) and (k%d == 0):
    nm =+ 1
    
    
A = b - a + 1
B = n + m - nm
print(A-B)

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n%m
  
  
g = n
l = (c*d)/g

s = (a-1)/c
t = (a-1)/d
u = (a-1)/l
x = b/c
y = b/d
z = b/l

B = b - (x + y - z)
A = a-1 -(s + t - u)

print(B - A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n%m
  
  
g = n
l = (c*d)/g

s1 = (a-1)/c
t1 = (a-1)/d
u1 = (a-1)/l
x1 = b/c
y1 = b/d
z1 = b/l

A = (x1 + y1 - z1) - (s1 + t1 - u1)

print(A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
g = n
l = (c*d)/g

s = (a-1)/c
t = (a-1)/d
u = (a-1)/l
x = b/c
y = b/d
z = b/l

B = b - (x + y - z)
A = a - 1 - (s + t - u)

print(B - A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

n = 0
m = 0
nm = 0
i = a
j = a
k = a

for i in range(a,b):
  if i % c == 0:
    n =+ 1
    
    
for j in range(a,b):
  if j % d == 0:
    m =+ 1

    
for k in range(a,b):
  if (k % c == 0) and (k % d == 0):
    nm =+ 1
    
    
print(n + m -nm)
    
    

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n%m
  
  
g = n

s1 = (a-1)/c
t1 = (a-1)/d
u1 = (a-1)/g
x1 = b/c
y1 = b/d
z1 = b/g

A = (x1 + x2 - x3) - (s1 + t1 - u1)

print(A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

n = 0
m = 0
nm = 0
i = 0
j = 0
k = 0

for i in range(a,b):
  if i % c == 0:
    n =+ 1
    
    
for j in range(a,b):
  if j % d == 0:
    m =+ 1

    
for k in range(a,b):
  if (k % c == 0) and (k % d == 0):
    nm =+ 1
    
    
print(n + m -nm)
    
    

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
g = n
l = (c*d)/g

s = (a-1)/c
t = (a-1)/d
u = (a-1)/l
x = b/c
y = b/d
z = b/l

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
l = (c*d)/n

s = int((a-1)/c)
t = int((a-1)/d)
u = int((a-1)/l)
x = int(b/c)
y = int(b/d)
z = int(b/l)

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n%m
  
  
g = n
l = (c*d)/g

s1 = (a-1)/c
t1 = (a-1)/d
u1 = (a-1)/l
x1 = b/c
y1 = b/d
z1 = b/l

A = (x1 + x2 - x3) - (s1 + t1 - u1)

print(A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
l = (c*d)//n

s = (a-1)//c
t = (a-1)//d
u = (a-1)//l
x = b//c
y = b//d
z = b//l

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A) 

i  = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

def gcd(n,m):
    x = min(n,m)
    y = max(n,m)
    while x != 0:
        x1 = x
        x = y%x
        y = x1
    return y

l = (c*d)/gcd(c,d)

count = (b - b//c - b//d + b//l) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//l)
print(count)

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
g = m
l = (c*d)/g

s = int((a-1)/c)
t = int((a-1)/d)
u = int((a-1)/l)
x = int(b/c)
y = int(b/d)
z = int(b/l)

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
g = n
l = int((c*d)/g)

s = int((a-1)/c)
t = int((a-1)/d)
u = int((a-1)/l)
x = int(b/c)
y = int(b/d)
z = int(b/l)

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
l = (c*d)//n

s = (a-1)//c
t = (a-1)//d
u = (a-1)//l
x = b//c
y = b//d
z = b//l

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A) 

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
l = (c*d)/n

s = int((a-1)/c)
t = int((a-1)/d)
u = int((a-1)/l)
x = int(b/c)
y = int(b/d)
z = int(b/l)

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A + 1) 

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

n = 0
m = 0
nm = 0

for i in range(a,b):
  if i % c == 0:
    n =+ 1
    
    
for j in range(a,b):
  if j % d == 0:
    m =+ 1

    
for k in range(a,b):
  if (k % c == 0) and (k % d == 0):
    nm =+ 1
    
    
print(n + m -nm)
    
    

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n%m
  
  
g = n
l = (c*d)/g

s1 = (a-1)/c
t1 = (a-1)/d
u1 = (a-1)/l
x1 = b/c
y1 = b/d
z1 = b/l

A = (x1 + y1 - z1) - (s1 + t1 - u1)

print(b-a+1-A)



  

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

n = 0
m = 0
nm = 0


for i in range(a,b):
  if i % c == 0:
    n =+ 1
    
    
for j in range(a,b):
  if j % d == 0:
    m =+ 1

    
for k in range(a,b):
  if (k % c == 0) and (k%d == 0):
    nm =+ 1
    
    
A = a+b
B = n + m - nm
print(A-B)
    
    

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

n = 0
m = 0
nm = 0

for i in range(a,b):
  if i % c == 0:
    n =+ 1
    
    
for j in range(a,b):
  if j % d == 0:
    m =+ 1

    
for k in range(a,b):
  if (k % c == 0) and (k % d == 0):
    nm =+ 1
    
    
A = a+b
B = n + m + nm
print(A-B)
    
    

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

n = 0
m = 0
nm = 0
e = c*d

for i in range(a,b):
  if i % c == 0:
    n =+ 1
    
    
for j in range(a,b):
  if j % d == 0:
    m =+ 1

    
for k in range(a,b):
  if k % e == 0:
    nm =+ 1
    
    
A = a+b
B = n + m - nm
print(A-B)
    
    

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]
 

n1 = b/c
n2 = b/d
n3 = b - n1 - n2

m1 = (a-1)/c
m2 = (a-1)/d
m3 = (a-1) - m1 - m2

print(n3 -m3)





i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
l = (c*d)//n

s = (a-1)//c
t = (a-1)//d
u = (a-1)//l
x = b//c
y = b//d
z = b//l

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A + 1) 

i = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

m = min(c,d)
n = max(c,d)

while m != 0:
  n = m
  m = n % m
  
  
l = (c*d)/n

s = int((a-1)/c)
t = int((a-1)/d)
u = int((a-1)/l)
x = int(b/c)
y = int(b/d)
z = int(b/l)

B = b - x - y + z
A = a - 1 - s - t + u

print(B - A + 1) 

i  = list(map(int,input().split()))
a = i[0]
b = i[1]
c = i[2]
d = i[3]

def gcd(n,m):
    x = min(n,m)
    y = max(n,m)
    while x != 0:
        x1 = x
        x = y%x
        y = x1
    return y

l = (c*d)//gcd(c,d)

count = (b - b//c - b//d + b//l) - ((a-1) - (a-1)//c - (a-1)//d + (a-1)//l)
print(count)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted