TnT/Multi_CodeNet4Repair huggingface dataset:
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):
def saidaikouyaku(a, b):
    if b > a:
        a, b = b, a

    while b != 0:
        a, b = b, (a % b)
    return a

A, B, C, D = map(int, input().split())
amari1 = 0
amari2 = 0
amari3 = 0
hani = B - A + 1
if B > C:
    amari1 = A % C
F = hani - amari1
Cnum = int(F / C) + 1
if B > D:
    amari2 = A % D
G = hani - amari2
Dnum = int(G / D) + 1
saisyoukoubai = int(C * D / saidaikouyaku(C, D))
if B > saisyoukoubai:
    amari3 = A % saisyoukoubai
H = hani - amari3
koubainum = int(H / saisyoukoubai) + 1
#print(hani)
#print(Cnum, Dnum, koubainum)
#print(amari1, amari2, amari3)
print(hani - Cnum - Dnum + koubainum)


def saidaikouyaku(a, b):
    if b > a:
        a, b = b, a

    while b != 0:
        a, b=b,(a%b)
    return a

A, B, C, D = map(int, input().split())
hani = B - A + 1
Cnum = B // C - (A - 1) // C
Dnum = B // D - (A - 1) // D
saisyoukoubai = C * D // saidaikouyaku(C, D)
koubainum = B // saisyoukoubai - int(A - 1) // saisyoukoubai
#print(hani)

print(hani - Cnum - Dnum + koubainum)


Verdicts: Wrong Answer

Accepted
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):
import fractions
A,B,C,D=map(int,input().split())

e=fractions.gcd(C,D)
a_c=(A-1)//C 
b_c=B//C  
a_d=(A-1)//D
b_d=B//D
a_cd=A//e
b_cd=B//e
s=A-1-(a_c+a_d-a_cd)　＃A-1以下の数字のうちCでもDでも割り切れないものの個数
t=B-(b_c+b_d-b_cd)　
u=t-s
print(u)

A,B,C,D=map(int,input().split())
s=0
for i in range(A,B+1):
  if i%C!=0 and i$D!=0:
    s+=1
print(s)

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)
s=(B-A)//C
t=(B-A)//D
u=(B-A)//lcm(C,D)
v=s+t-u
print(B-A+1-u)


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)
def main(a,b,c):
  if a%c==0 or b%c==0:
    s=(b-a)//c+1
  else:
    s=(b-a)//c
  return s
S=main(A,B,C)
T=main(A,B,D)
U=main(A,B,lcm(C,D))
V=S+T-U
print(B-A+1-V)

import fractions
A,B,C,D=map(int,input().split())

e=fractions.gcd(C,D)
a_c=(A-1)//C 
b_c=B//C  
a_d=(A-1)//D
b_d=B//D
if e==C*D:
  s=A-1-(a_c+a_d)
  t=B-(b_c+b_d)
  u=t-s
  print(u)
else:
  a_cd=(A-1)//e 
  b_cd=B//e
  s=A-1-(a_c+a_d-a_cd)
  t=B-(b_c+b_d-b_cd)
  u=t-s
  print(u)

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)
def main(a,b,c):
  if a%c==0 or b%c==0:
    s=((b-a)//c)+1
  else:
    s=(b-a)//c
  return s
S=main(A,B,C)
T=main(A,B,D)
U=main(A,B,lcm(C,D))
V=S+T-U
print(B-A+1-V)

import fractions
A,B,C,D=map(int,input().split())

e=fractions.gcd(C,D)
a_c=A//C 
b_c=B//C  
a_d=A//D
b_d=B//D
if e==C*D:
  s=A-(a_c+a_d)
  t=B-(b_c+b_d)
  u=t-s
  print(u)
else:
  a_cd=A//e 
  b_cd=B//e
  s=A-(a_c+a_d-a_cd)
  t=B-(b_c+b_d-b_cd)
  u=t-s
  print(u)
  
  
  

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)
s=(A-1)//C
t=(A-1)//D
u=(A-1)//lcm(C,D)
v=s+t-u
w=A-1-v
S=B//C
T=B//D
U=B//lcm(C,D)
V=S+T-U
W=B-V
print(W-w)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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):
A,B,C,D=map(int, input().split())

def gcd(a,b):
  while b:
    a, b = b, a%b
  return a

def lcm(x,y):
  return x/gcd(x,y)*y
  
ans = (B - B//C - B//D + B//lcm(C,D) ) - ( (A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm(C,D) )
print(ans)

def gcd(a,b):
  while b:
    a, b = b, a%b
  return a

def lcm(a,b):
  return a*b//gcd(a,b)

def g(X):
  return X - X//C - X//D + X//lcm(C,D)

A,B,C,D=map(int, input().split())

ans = g(B) - g(A-1)
print(ans)

Verdicts: Wrong Answer

Accepted
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):
from fractions import gcd
def floor(a, b):
  return int((a - a%b)/b)

#   while a % b != 0:
#       a, b = b, a % b
#   return a
def lcm(a, b):
  return floor((a * b), gcd(a, b))
input = list(map(int, input().split(' ')))
total_count = input[1] + 1 - input[0]
div_c = floor(input[1], input[2]) - floor(input[0] -1, input[2])
div_d = floor(input[1], input[3]) - floor(input[0] -1, input[3])
div_cd = floor(input[1], lcm(input[2], input[3])) - floor(input[0] -1, lcm(input[2], input[3]))
print(total_count - (div_c + div_d - div_cd))

def gcd (a, b):
    while b!=0:
        a, b = b, a%b
    return a

def lcm(a, b):
    return (a*b) // gcd(a, b)

input = input().split(' ')
A = int(input[0])
B = int(input[1])
C = int(input[2])
D = int(input[3])

div_c = B//C - (A-1)//C
div_d = B//D - (A-1)//D
div_cd = B//lcm(C, D) - (A-1)//lcm(C, D)

print(B-A+1-(div_c+div_d-div_cd))

Verdicts: Wrong Answer

Accepted
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):
a,b,c,d=map(int,input().split())

def calc_div_num(a,b,x):
  return b//x - (a-1)//x

num_c = b//c - (a-1)//c
num_d = b//d - (a-1)//d

import numpy as np
lcd = np.lcd(c,d)
num_lcd = b//lcd - (a-1)//lcd

result = b-a+1 - (num_c+num_d-num_lcd)
print(result)

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

num_c = b//c - a//c
num_d = b//d - a//d

import numpy as np
lcd = np.lcm(c, d)
num_lcd = b//lcd - a//lcd

result = b-a+1 - (num_c+num_d-num_lcd)
print(result)

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

def calc_div_num(a,b,x):
  return b//x - (a-1)//x

num_c = calc_div_num(a, b, c)
num_d = calc_div_num(a, b, d)

import numpy as np
import math
#lcd = np.lcm(c, d)
lcd = c*d/math.gcd(c,d)
num_lcd = calc_div_num(a, b, lcd)

result = b-a+1 - (num_c+num_d-num_lcd)
print(result)

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

def calc_div_num(a,b,x):
  return b//x - (a-1)//x

num_c = b//c - (a-1)//c
num_d = b//d - (a-1)//d

import math
lcd = int(c * d / math.gcd(c,d))
num_lcd = b//lcd - (a-1)//lcd

result = b-a+1 - (num_c+num_d-num_lcd)
print(result)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
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):
def GCD(s, t):
    if s < t:
        s, t = t, s
    if t == 0:
        return s
    else:
        return GCD(t,s%t)

A, B, C, D = map(int, input().split())
E = C*D // GCD(C,D)
x = B // C - A // C
y = B // D - A // D
z = B // E - A // E
print(B-A-x-y+z+1)

def GCD(s, t):
    if s < t:
        s, t = t, s
    if t == 0:
        return s
    else:
        return GCD(t,s%t)

A, B, C, D = map(int, input().split())
E = C*D // GCD(C,D)
x = B // C - (A-1) // C
y = B // D - (A-1) // D
z = B // E - (A-1) // E
print(B-A-x-y+z+1)

Verdicts: Wrong Answer

Accepted
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):
import fractions as math

def main():
    a,b,c,d = map(int, input().split())
    al = b-a+1
    x = al // c
    y = al // d
    z = al // (c/math.gcd(c,d)*d)
    an = x+y-z
    #print(al, an)
    print(int(al-an))
    
if __name__ == "__main__":
    main()

import math
def main():
    a,b,c,d = map(int,input().split())
    bc = b // c
    bd = b // d
    bx = b // (c * d // math.gcd(c,d))
    B = b - bc - bd + bx
    
    a -= 1
    ac = a // c
    ad = a // d
    ax = a // (c * d // math.gcd(c,d))
    A = a - ac - ad + ax
    
    print(B-A)
    
if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
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):
import sys
input = sys.stdin.readline
def main():
    A, B, C, D = map(int, input().split())
    N = B-A+1
    NC = (N+C-1)//C
    ND = (N+D-1)//D
    NCD = (N+C*D+1)//(C*D)
    ans = N - NC - ND + NCD

    print(ans)

if __name__ == '__main__':
    main()

import sys
input = sys.stdin.readline
def main():
    A, B, C, D = map(int, input().split())
    N = B-A+1
    NC = (N+C-1)//C
    ND = (N+D-1)//D
    NCD = (N+C*D+1)//(C*D)
    ans = N - NC - ND + NCD
    print(N, NC, ND, NCD)
    print(ans)

if __name__ == '__main__':
    main()

import sys
input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def main():
    A, B, C, D = map(int, input().split())
    g = gcd(max(C,D),min(C,D))
    l = C*D//g
    NB = B - B//C - B//D + B//l
    NA = (A-1) - (A-1)//C - (A-1)//D + (A-1)//l
    ans = NB - NA
    print(int(ans))

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
A,B,C,D=map(int,input().split())
c=C*D/gcd(C,D)
b=B//C+B//D-B//c
a=(A-1)//C+(A-1)//D-(A-1)//c
print((B-b)-(A-1-a))

def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
A,B,C,D=map(int,input().split())
c=int(C*D/gcd(C,D))
b=int(B//C)+int(B//D)-int(B//c)
a=int((A-1)//C)+int((A-1)//D)-int((A-1)//c)
print(int((B-b)-(A-1-a)))

Verdicts: Wrong Answer

Accepted
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):
from fractions import gcd
from math import ceil
a,b,c,d = map(int, input().split())

nums = b-a+1
t1 = ceil(b/c - a/c)
t2 = ceil(b/d - a/d)

lcm = (c*d)//gcd(c,d)
t3 = b//lcm - a//lcm
print(nums-t1-t2+t3)

from fractions import gcd
a,b,c,d = map(int, input().split())

nums = b-a+1
t1 = b//c - a//c
t2 = b//d - a//d

lcm = (c*d)//gcd(c,d)
t3 = b//lcm - a//lcm
print(nums-t1-t2+t3)

from math import gcd
a,b,c,d = map(int, input().split())

s = b - ((b//c)+(b//d)) + b//((c*d)//gcd(c,d))
t = (a-1) - (((a-1)//c)+((a-1)//d)) + (a-1)//((c*d)//gcd(c,d))
print(s-t)

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):

A, B, C, D = map(int, input().split())

def gcd(c, d):
    if c < d:
        return gcd(d, c)
    
    while d != 0:
        s = c % d
        c = d
        d = s
        
    return c
    
def lcm(c, d):
    return c * d // gcd(c, d)
    
print(gcd(C, D))
print(lcm(C, D))

c = B // C - A // C if A % C == 0 else B // C - (A // C + 1)
d = B // D - A // D if A % D == 0 else B // D - (A // D + 1)

LCM = lcm(C, D)

LCM = B // LCM - A // LCM if A % LCM == 0 else B // LCM - (A // LCM + 1)

c += 1
d += 1
LCM += 1

#print(c, d, LCM)

print(B - A + 1 - c - d + 1)


def gcd(c, d):
    if c < d:
        return gcd(d, c)
    
    while d != 0:
        s = c % d
        c = d
        d = s
        
    return c
    
def lcm(c, d):
    return c * d // gcd(c, d)

A, B, C, D = map(int, input().split())


c = B // C - A // C if A % C == 0 else B // C - (A // C + 1)
d = B // D - A // D if A % D == 0 else B // D - (A // D + 1)

LCM = lcm(C, D)

LCM = B // LCM - A // LCM if A % LCM == 0 else B // LCM - (A // LCM + 1)

c += 1
d += 1
LCM += 1

#print(c, d, LCM)

print(B - A + 1 - c - d + LCM)

Verdicts: Wrong Answer

Accepted
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):
def gcd(x, y): 
	while(y): 
   		x, y = y, x % y 
	return x 
a,b,c,d=map(int,input().split())
m=((c*d)//(gcd(c,d)))
di=b-a+1
if a%c==0:
  c1=(b//c-a//c)+1
else:
  c1=(b//c-a//c)
if a%d==0:
  c2=(b//d-a//d)+1
else:
  c2=(b//d-a//d)
if a%m==0 and m!=a or m!=b:
  c3=(b//m-a//m)+1
else:
  c3=(b//m-a//m)
print(di-(c1+c2-c3))  


def gcd(x, y): 
	while(y): 
   		x, y = y, x % y 
	return x 
a,b,c,d=map(int,input().split())
m=((c*d)//(gcd(c,d)))
di=b-a
if a%c==0:
  c1=(b//c-a//c)+1
else:
  c1=(b//c-a//c)
if a%d==0:
  c2=(b//d-a//d)+1
else:
  c2=(b//d-a//d)
if a%m==0 and m!=a or m!=b:
  c3=(b//m-a//m)+1
else:
  c3=(b//m-a//m)
print(di-(c1+c2-c3-c3))  


def gcd(x, y): 
	while(y): 
   		x, y = y, x % y 
	return x 
a,b,c,d=map(int,input().split())
m=((c*d)//(gcd(c,d)))
di=b-a
if a%c==0:
  c1=(b//c-a//c)+1
else:
  c1=(b//c-a//c)
if a%d==0:
  c2=(b//d-a//d)+1
else:
  c2=(b//d-a//d)
if a%m==0:
  c3=(b//m-a//m)+1
else:
  c3=(b//m-a//m)
print(di-(c1+c2-c3-c3)+1)  


def gcd(x, y): 
	while(y): 
   		x, y = y, x % y 
	return x 
a,b,c,d=map(int,input().split())
m=((c*d)//(gcd(c,d)))
di=b-a+1
if a%c==0:
  c1=(b//c-a//c)+1
else:
  c1=(b//c-a//c)
if a%d==0:
  c2=(b//d-a//d)+1
else:
  c2=(b//d-a//d)
if a%m==0:
  c3=(b//m-a//m)+1
else:
  c3=(b//m-a//m)
print(di-(c1+c2-c3))  


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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):
a, b, c, d = map(int,input().split())
li = [i for i in range(a, b+1)]
print(li)
cf = [True if i%c != 0 else False for i in li]
print(cf)
df = [True if i%d != 0 else False for i in li]
print(df)
n = 0
for i in range(len(cf)):
    if cf[i] and df[i]:
        n+=1
print(n)

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)

def calc(n):
    return n-n//C-n//D+n//(lcm(C,D))
 
print(calc(B)-calc(A-1))

Verdicts: Wrong Answer

Accepted
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):
import math
a,b,c,d=map(int,input().split())
lcm=(c*d)//math.gcd(c,d)
ans=(b-a)-((b//c-a//c)+(b//d-a//d)-(b//lcm-a//lcm))+1
print(ans)

import math
a,b,c,d=map(int,input().split())
lcm=(c*d)//math.gcd(c,d)
ans=(b-a)-((b//c-(a-1)//c)+(b//d-(a-1)//d)-(b//lcm-(a-1)//lcm))+1
print(ans)

Verdicts: Wrong Answer

Accepted
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):
A, B, C, D = map(int, input().split())
numC = B//C - A//C
numD = B//D - A//D

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if a % b == 0:
        return b
    return gcd(b, a%b)

CD = C * D // gcd(C, D)

numCD = B//CD - A//CD
numAll = B - A + 1
print(numAll - numC - numD + numCD)


A, B, C, D = map(int, input().split())

numC = B//C - (A-1)//C
numD = B//D - (A-1)//D

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if a % b == 0:
        return b
    return gcd(b, a%b)

CD = C * D // gcd(C, D)

numCD = B//CD - (A-1)//CD
numAll = B - A + 1
print(numAll - numC - numD + numCD)


Verdicts: Wrong Answer

Accepted
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):
import math

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

ac_r = a % c
ad_r = a % d
lcm =  (c*d) // math.gcd(c, d)
acd_r = a % lcm
n = b - a + 1

if (ac_r == 0 and n % c == 1) or ((ac_r == 0 and n % c == 2) or (ac_r == 2 and n % c == 2)) :
    n_c = n // c + 1
else:
    n_c = n // c
    
if (ad_r == 0 and n % d == 1) or ((ad_r == 0 and n % d == 2) or (ad_r == 2 and n % d == 2)):
    n_d = n // d + 1
else:
    n_d = n // d
    
if (acd_r == 0 and n % (c*d) == 1) or ((acd_r == 0 and n % (c*d) == 2) or (acd_r == 2 and n % (c*d) == 2)):
    n_cd = n // lcm + 1
else:
    n_cd = n // lcm
    
print(n - (n_c + n_d - n_cd)) 
print(ac_r, ad_r, acd_r, n)

import math

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

ac_r = a % c
ad_r = a % d
lcm =  (c*d) // math.gcd(c, d)
acd_r = a % lcm
n = b - a + 1

if (ac_r == 0 and n % c == 1) or ((ac_r == 0 and n % c == 2) or (ac_r == 2 and n % c == 2)) :
    n_c = n // c + 1
else:
    n_c = n // c
    
if (ad_r == 0 and n % d == 1) or ((ad_r == 0 and n % d == 2) or (ad_r == 2 and n % d == 2)):
    n_d = n // d + 1
else:
    n_d = n // d
    
if (acd_r == 0 and n % (c*d) == 1) or ((acd_r == 0 and n % (c*d) == 2) or (acd_r == 2 and n % (c*d) == 2)):
    n_cd = n // lcm + 1
else:
    n_cd = n // lcm
    
print(n - (n_c + n_d - n_cd)) 
print(ac_r, ad_r, acd_r, n)

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

ac_r = a % c
ad_r = a % d
acd_r = a % (c*d)

if (ac_r == 0 and n % c == 1) or ((ac_r == 0 and n % c == 2) or (ac_r == 2 and n % c == 2)) :
    n_c = (b - a + 1) // c + 1
else:
    n_c = (b - a + 1) // c
    
if (ad_r == 0 and n % d == 1) or ((ad_r == 0 and n % d == 2) or (ad_r == 2 and n % d == 2)):
    n_d = (b - a + 1) // d + 1
else:
    n_d = (b - a + 1) // d
    
if (acd_r == 0 and n % (c*d) == 1) or ((acd_r == 0 and n % (c*d) == 2) or (acd_r == 2 and n % (c*d) == 2)):
    n_cd = (b - a + 1) // (c*d) + 1
else:
    n_cd = (b - a + 1) // (c*d)
    
print((b - a + 1) - (n_c + n_d - n_cd))    

def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)
 
def lcm(a, b):
    return a // gcd(a, b) * b

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

n = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm(c,d) - (a-1)//lcm(c,d)

print(n - n_c - n_d + n_cd)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
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):
import sys
import math
from fractions import gcd

def lcm(a, b):
  return (a * b) // gcd(a, b)

a,b,c,d = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
e = b - a + 1
f = int(b / c) - int((a - 1) / c)
g = int(b / d) - int((a - 1) / d)
cd = lcm(c, d) 
h = int(b / cd) - int((a - 1) / cd)
n = e - f - g + h 
print(n)


import sys
import math

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

def lcm(a, b):
  return (a * b) // gcd(a, b)

  
a,b,c,d = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
e = b - a + 1
if c == d:
  fgh = (b // c) - ((a - 1) // c)
  n = e - fgh
  print(n) 
else:
  f = (b // c) - ((a - 1) // c)
  g = (b // d) - ((a - 1) // d)
  cd = lcm(c, d) 
  h = (b // cd) - ((a - 1) // cd)
  n = e - f - g + h
  print(n)


Verdicts: Wrong Answer

Accepted
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):
import math

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

a,b,c,d=map(int,input().split())
d1=math.floor(b/c)
d2=math.floor(b/d)
d3=math.floor(b/lcm(c,d))

d4=math.floor((a-1)/c)
d5=math.floor((a-1)/d)
d6=math.floor((a-1)/lcm(c,d))

ansb=b-(d1+d2-d3)
ansa=a-1-(d1+d2-d3)
print(ansb-ansa)

def gcd(x,y):
    if x < y:
        x,y = y,x
        
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

def lcm(x,y):
    return (x*y)//gcd(x,y)

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

al = b-a+1

cnt_c = b//c - (a-1)//c 

cnt_d = b//d - (a-1)//d 

cnt_t = b//lcm(c,d) - (a-1)//lcm(c,d) 

print(al - cnt_c - cnt_d + cnt_t)

Verdicts: Runtime Error

Accepted
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):
import math

A,B,C,D = map(int,input().split())
count = 0

QC = 0 
QD = 0 
QCD = 0 

CD = int(C * D / math.gcd(C, D)) 
print(CD)


QC = (B // C) - (A // C)
if A % C == 0:
        QC += 1

QD = (B // D) - (A // D)
if A % D == 0:
        QD += 1

QCD = (B // CD) - (A // CD)
if A % CD == 0:
        QCD += 1

N = B-A+1
CorD = QC+QD-QCD

print(N-CorD)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

A,B,C,D = map(int,input().split())
count = 0

QC = 0 
QD = 0 
QCD = 0 

CD = lcm(C,D) 


QC = (B // C) - (A // C)
if A % C == 0:
        QC += 1

QD = (B // D) - (A // D)
if A % D == 0:
        QD += 1

QCD = (B // CD) - (A // CD)
if A % CD == 0:
        QCD += 1

N = B-A+1
CorD = QC+QD-QCD

print(N-CorD)

Verdicts: Runtime Error

Accepted
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):
import fractions
a,b,c,d = map(int,input().split())
e,f,g,h,i,j = b//c,b//d,(a-1)//c,(a-1)//d,b//((c*d)/fractions.gcd(c,d)),(a-1)//((c*d)/fractions.gcd(c,d))
print(int(b-(e+f-i)-(a-1-(g+h-j))))

import math
a,b,c,d = map(int,input().split())
lcm = c*d//(math.gcd(c,d))
e,f,g = b//c - (a-1)//c,b//d - (a-1)//d,b//(lcm) - (a-1)//(lcm)
print(b-a+1-e-f+g)

Verdicts: Wrong Answer

Accepted
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):
import fractions
A,B,C,D = map(int,input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0

if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
    last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
    last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)


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)
CD = lcm(C,D)
c_div = 0
d_div = 0
cd_div = 0
ans = 0
if A % C == 0:
    first_C = A
else:
    first_C = A + C -(A%C)
last_C = B -(B%C)
c_div = (last_C - first_C)//C + 1

if A % D == 0:
    first_D = A
else:
    first_D = A + D -(A%D)
last_D = B - (B%D)
d_div = (last_D - first_D)//D + 1

if A % CD == 0:
    first_CD =A
else:
    first_CD = A + CD -(A%CD)
last_CD = B -(B%CD)
cd_div = (last_CD - first_CD)//CD + 1

ans = c_div + d_div -cd_div
print(B-A+1-ans)


Verdicts: Runtime Error

Accepted
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):
def gcd(a, b):
    a, b = sorted([a, b])
    while(b != 0):
        a, b = (b, a%b)
    return b

def getMultiCount(start, end, times):
    if end < times: return 0
    s = start-(start%times)
    if s != start: s += times
    e = end-(end%times)
    if s > e: return 0
    return ((e-s)//times)+1
    
def answer(a, b, c, d):
    cCount = getMultiCount(a, b, c)
    dCount = getMultiCount(a, b, d)
    cdCount = getMultiCount(a, b, c*d//gcd(c,d))
    return (b-a+1)-(cCount + dCount - cdCount)

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

def gcd(a, b):
    a, b = sorted([a, b], reverse=True)
    while(b != 0):
        a, b = (b, a%b)
    return a

def getMultiCount(start, end, times):
    if end < times: return 0
    s = start-(start%times)
    if s != start: s += times
    e = end-(end%times)
    if s > e: return 0
    return ((e-s)//times)+1
    
def answer(a, b, c, d):
    cCount = getMultiCount(a, b, c)
    dCount = getMultiCount(a, b, d)
    cdCount = getMultiCount(a, b, c*d//gcd(c,d))
    return (b-a+1)-(cCount + dCount - cdCount)

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

Verdicts: Runtime Error

Accepted
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):
a, b, c, d = map(int, input().split())
count = 0
ab = a * b
target = b - a + 1
if (a % c == 0 or b % c == 0) or (a % d == 0 or b % d == 0):
  count += int(target // c) + 1
  count += int(target // d) + 1
  tmp_cou = 0
  while d <= c:
    d = d / ab
    tmp_cou += 1
  count -= tmp_cou
else:
  count += int(target // c)
  count += int(target // d)
  tmp_cou = 0
  while d <= c:
    d = d / ab
    tmp_cou += 1
  count -= tmp_cou
print(target - count)

import sys
a, b, c, d = map(int, input().split())
target = b - a + 1

def gcd(x,y):
  while y!=0:
    x,y=y,x%y
  return x
def lcm(x, y):
    return (x * y) // gcd(x, y)

b_num = b//c + b//d -b//lcm(c,d)
a_num = (a-1)//c + (a-1)//d - (a-1)//lcm(c,d)
print(target - (b_num - a_num))

Verdicts: Wrong Answer

Accepted
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):
import math
A,B,C,D = map(int,input().split())

print(B-B//C-B//D+B//(C*D//math.gcd(C,D))-(A-A//C-A//D+A//(C*D//math.gcd(C,D)))+1)

from math import gcd
A, B, C, D = map(int,input().split())
 
lcm = C*D // gcd(C,D)
a = (A-1)//C + (A-1)//D - (A-1)//lcm
b = B//C + B//D - B//lcm
 
print(B-A+1-b+a)

Verdicts: Wrong Answer

Accepted
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):
from math
a,b,c,d=list(map(int,input().split()))
a-=1
def calculation(x,c,d):
	x=x-(x//c)-(x//d)+(x//((c*d)//math.gcd(c,d)))
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))

import math
a,b,c,d=list(map(int,input().split()))
a-=1
def calculation(x,c,d):
	x=x-(x//c)-(x//d)+(x//((c*d)//math.gcd(c,d)))
	return x
	
print(calculation(b,c,d)-calculation(a,c,d))

Verdicts: Runtime Error

Accepted
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):
L, R = map(int, input().split())

ans = 2019
for i in range(L, R):
    f = False
    for j in range(i, R):
        if  ((i*j) % 2019) == 0:
            print(0)
            break
        ans = min(ans, (i*j)%2019)
    if f:
        break
print(ans)

import math

A, B, C, D = map(int, input().split())
ans=0

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

lcmCD=lcm(C, D)
ans=B-A+1
ans-=((B//C) - (A//C))
ans-=((B//D) - (A//D))
ans+=((B//lcmCD) - (A//lcmCD))
print(ans)


A, B, C, D = map(int, input().split())
ans=0

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

def lcm(x, y):
    return (x * y) // gcd(x, y)

lcmCD=lcm(C, D)
ans=B-A+1
ans-=((B//C) - ((A-1)//C))
ans-=((B//D) - ((A-1)//D))
ans+=((B//lcmCD) - ((A-1)//lcmCD))
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
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):
a, b, c, d = map(int, input().split())
N = list(range(a, b+1, 1))
t = 0
for n in N:
  if n % c == 0 and n % d == 0:
    t += 1
print(t)

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

s1 = (a-1) // c
s2 = (a-1) // d
s3 = (a-1) // (c*d//math.gcd(c,d))
S = (a-1) - (s1 + s2 -s3)

l1 = b // c
l2 = b // d
l3 = b // (c*d//math.gcd(c,d))
L = b - (l1 + l2 - l3)

print(L-S)

Verdicts: Runtime Error

Accepted
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):
a,b,c,d = map(int, input().split())

c1, d1, cd1 = b // c, b // d, b // (c*d)
c2, d2, cd2 = (a-1) // c, (a-1) // d, a // (c*d)
ans = (c1+d1-cd1) - (c2+d2-cd2)
print(ans)
print((b-a+1) - ans)

from fractions import gcd
a,b,c,d = map(int, input().split())
x = (c*d) // gcd(c,d)
c1, d1, cd1 = b // c, b // d, b // x
c2, d2, cd2 = (a-1) // c, (a-1) // d, a // x
ans = (c1+d1-cd1) - (c2+d2-cd2)
print(b-a+1-ans)

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

C = b//c - (a-1)//c
D = b//d - (a-1)//d
x = c*d//math.gcd(c,d)
CD = b//x - (a-1)//x

print((b-a+1) - (C+D-CD))

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
def euclid(a,b):
	c=0
	if (a-b)<0:
		c=a
		a=b
		b=c
	r=-1
	while r!=0:
		r=a%b
		a=b
		b=r
	return a

A,B,C,D=map(int,input().split())
c1=A//C
d1=A//D
c2=B//C
d2=B//D
k=euclid(C,D)
CD=C*D//k
cd1=A//CD
cd2=B//CD
c3=c2-c1
d3=d2-d1
cd3=cd2-cd1
print(B-A+1-c3-d3+cd3)

def euclid(a,b):
	c=0
	if (a-b)<0:
		c=a
		a=b
		b=c
	r=-1
	while r!=0:
		r=a%b
		a=b
		b=r
	return a

A,B,C,D=map(int,input().split())
c1=(A-1)//C
d1=(A-1)//D
c2=B//C
d2=B//D
k=euclid(C,D)
CD=C*D//k
cd1=(A-1)//CD
cd2=B//CD
c3=c2-c1
d3=d2-d1
cd3=cd2-cd1
print(B-A+1-c3-d3+cd3)

Verdicts: Wrong Answer

Accepted
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):

def euclid_gcd(a,b):
    while b:
        a, b = b, a%b
    return a


def euclid_lcm(a, b):
    return a * b // euclid_gcd(a, b)
    
A,B,C,D = map(int,input().split())

X = euclid_lcm(C,D)
A = A-1

Y = A//C + A//D - A//X
Z = B//C + B//D - B//X
 
print(B-Z - (A-Y)


def euclid_gcd(a,b):
    while b:
        a, b = b, a % b
    return a


def euclid_lcm(a, b):
    return a * b // euclid_gcd(a, b)
    
A,B,C,D = map(int,input().split())

X = euclid_lcm(C,D)
A = A-1

Y = A//C + A//D - A//X
Z = B//C + B//D - B//X
 
print(B-Z - (A-Y))

Verdicts: Runtime Error

Accepted
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):
a,b,c,d = map(int, input().split())
e = int((b-a)/c)
f = int((b-a)/d)
r = e+f
print((b-a)-(r)+1)

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return a*b // gcd(a,b)

a,b,c,d = map(int,input().split())
a -= 1
A = a-((a//c) + (a//d) - a//lcm(c,d))
B = b-((b//c) + (b//d) - b//lcm(c,d))
print(B-A)

Verdicts: Wrong Answer

Accepted
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):
import math

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



def f(x,y):
  z=x//y
  return z


a,b,c,d=map(int,input().split())
g=gcd(c,d)
p=a-f(a,c)-f(a,d)+f(a,c*d/g)
q=b-f(b,c)-f(b,d)+f(b,c*d/g)
if(a%c!=0 and a%d!=0):
  print(q-p+1)
else:
  print(q-p)

import math

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



def f(x,y):
  z=int(x//y)
  return z


a,b,c,d=map(int,input().split())
g=gcd(c,d)
p=a-f(a,c)-f(a,d)+f(a,int(c*d/g))
q=b-f(b,c)-f(b,d)+f(b,int(c*d/g))
if(a%c!=0 and a%d!=0):
  print(q-p+1)
else:
  print(q-p)

Verdicts: Wrong Answer

Accepted
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):
def gcd(x, y):  
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


def lcm(x, y):
    return x*y // (gcd(x, y))


def num(n, c, d):
    c = n // c
    d = n // d
    cd = n // (lcm(c, d))
    return n - c - d + cd


a, b, c, d = map(int, input().split())
print(int(num(b, c, d) - num(a-1, c, d)))

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

def lcm(a, b):
    return a*b//(gcd(a, b))

def num(n, c, d):
    dc = n//c
    dd = n//d
    dcd = n//(lcm(c, d))
    return n-dc-dd+dcd

a, b, c, d = map(int, input().split())
print(num(b, c, d) - num(a-1, c, d))

Verdicts: Runtime Error

Accepted
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):
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a,b,c,d = map(int,input().split())
c_i=a//c
d_i=a//d
cd_i=a//(lcm(c,d))
if not a%c==0:
    c_i+=1
if not a%d==0:
    d_i+=1
if not a%(lcm(c,d))==0:
    cd_i+=1

c_f=b//c
d_f=b//d
cd_f=b//(lcm(c,d))

print(b-a-(c_f+d_f-cd_f-c_i-d_i+cd_i+1)+1)


def gcd(m,n):
    x= max(m,n)
    y= min(m,n)
    if x%y == 0:
        return y
    else:
        while not x%y==0:
            z=x%y
            x= y
            y=z
        else:
            return z
def lcm(x, y):
    return (x * y) // gcd(x, y)


a,b,c,d = map(int,input().split())
lcm = lcm(c,d)
c_i=a//c
d_i=a//d
cd_i=a//lcm
if not a%c==0:
    c_i+=1
if not a%d==0:
    d_i+=1
if not a%lcm==0:
    cd_i+=1

c_f=b//c
d_f=b//d
cd_f=b//lcm

print(b-a-(c_f+d_f-cd_f-c_i-d_i+cd_i+1)+1)


Verdicts: Runtime Error

Accepted
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):
def warikire(warare,waru):
    if warare%waru==0:
        return True
    return False

a,b,c,d=map(int,input().split())
cnt1=0
cnt2=0
cnt3=0
swi=0
ans1=0
ans2=0
ans3=0

for i in range(a,b+1):
    if swi==1:
        break
    if warikire(i,c):
        cnt1=i
        swi=1
swi=0
for i in range(a,b+1):
    if swi==1:
        break
    if warikire(i,d):
        cnt2=i
        swi=1
swi=0        
for i in range(a,b+1):
    if swi==1:
        break
    if warikire(i,c*d):
        cnt3=i
        swi=1

#print(cnt1,cnt2,cnt3)
ans1=(b-cnt1)//c
print(ans1)
ans2=(b-cnt2)//d
print(ans2)
ans3=(b-cnt3)//(c*d)
print(ans3)
print(b-a-(ans1+ans2-ans3))


def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return(a)

a,b,c,d=map(int,input().split())
cn1=0
cn2=0
cn3=0
an1=0
an2=0
an3=0
cnt=0
ans=0
lm=(c*d)//gcd(c,d)


cn1=b//c
cn2=b//d
cn3=b//lm

an1=(a-1)//c
an2=(a-1)//d
an3=(a-1)//lm

cn1=cn1-an1
cn2=cn2-an2
cn3=cn3-an3

cnt=cn1+cn2-cn3
ans=b-a-cnt

print(ans+1)


Verdicts: Wrong Answer

Accepted
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):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
inputs = [int(s) for s in input().split()]
a = inputs[0]
b = inputs[1]
c = inputs[2]
d = inputs[3]
count = 0
minCD = min(c, d)
maxCD = max(c, d)

x0 = b-a+1
x1 = b//minCD - (a-1)//minCD
x2 = b//maxCD - (a-1)//maxCD
lcm = minCD * maxCD // gcd(minCD, maxCD)
x3 = b//lcm - (a-1)//lcm
print(x0, x1, x2, x3)
if maxCD % minCD == 0:
    print(x0-x1)
else:
    print(x0-(x1+x2-x3))

import math
inputs = [int(s) for s in input().split()]
a = inputs[0]
b = inputs[1]
c = inputs[2]
d = inputs[3]
count = 0
minCD = min(c, d)
maxCD = max(c, d)

x0 = b-a+1
x1 = b//minCD - (a-1)//minCD
x2 = b//maxCD - (a-1)//maxCD
lcm = minCD * maxCD // math.gcd(minCD, maxCD)
x3 = b//lcm - (a-1)//lcm
print(x0, x1, x2, x3)
if maxCD % minCD == 0:
    print(x0-x1)
else:
    print(x0-(x1+x2-x3))


def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
inputs = [int(s) for s in input().split()]
a = inputs[0]
b = inputs[1]
c = inputs[2]
d = inputs[3]
count = 0
minCD = min(c, d)
maxCD = max(c, d)

x0 = b-a+1
x1 = b//minCD - (a-1)//minCD
x2 = b//maxCD - (a-1)//maxCD
lcm = minCD * maxCD // gcd(minCD, maxCD)
x3 = b//lcm - (a-1)//lcm
if maxCD % minCD == 0:
    print(x0-x1)
else:
    print(x0-(x1+x2-x3))

Verdicts: Wrong Answer

Runtime Error

Accepted
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):
# input
A, B, C, D = int(input())


ans = len([1 for i in range(A, B + 1) if i % C != 0 and i % D != 0])

print(ans)




def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    z = None
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        return z


def lcm(m, n):
    return (m * n) // gcd(m, n)


# input
A, B, C, D = map(int, input().split())


AB = B - (A - 1)

C_cnt = B // C - (A - 1) // C
D_cnt = B // D - (A - 1) // D

lcm_CD = lcm(C, D)
lcm_cnt = B // lcm_CD - (A - 1) // lcm_CD

ans = AB - C_cnt - D_cnt + lcm_cnt

print(ans)

Verdicts: Runtime Error

Accepted
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):
A,B,C,D = map(int, input().split())

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

def count(n):
    c = n//C
    d = n//D
    g = gcd(C, D)
    l = C*D//gcd
    return n -c -d +n//l

print(count(B) - count(A-1))


A,B,C,D = map(int, input().split())

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

def count(n):
    c = n//C
    d = n//D
    g = gcd(C, D)
    l = C*D//g
    return n -c -d +n//l

print(count(B) - count(A-1))


Verdicts: Runtime Error

Accepted
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):
import math
A,B,C,D=map(int ,input().split())
a = B//C-A//C
b = B//D-A//D
c  = math.gcd(C,D)
d = B//c-A//c
e = B - A - a -b + d 
print(e)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D=map(int ,input().split())
a = B//C-(A-1)//C
b = B//D-(A-1)//D
c  =lcm(C,D)
d = B//c-(A-1)//c
e = B - A +1 - a -b + d 
print(e)

Verdicts: Runtime Error

Accepted
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):
# C
def gcd(a,b):
    if a<b: a,b = b,a
    r = a % b
    while(r!=0):
        a,b = b,r
    return b


def nonDivided(n,s,t):
    if not n > 0:
        return 0
    else:
        return n-int(n/s)-int(n/t)+int(n*gcd(s,t)/(s*t))

if __name__=='__main__':
    a,b,c,d = map(int,input().split())
    print(nonDivided(b,c,d)-nonDivided(a-1,c,d))

# C
def gcd(a,b):
    if a<b: a,b = b,a
    r = a % b
    while(r!=0):
        a,b = b,r
        r = a%b
    return b

def nonDivided(n,s,t):
    if not n > 0:
        return 0
    else:
        lcm = int(s/gcd(s,t)*t)
        return n-n//s-n//t+n//lcm

if __name__=='__main__':
    A,B,C,D = map(int,input().split())
    print(nonDivided(B,C,D)-nonDivided(A-1,C,D))

Verdicts: Wrong Answer

Accepted
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):
import math
A, B, C, D = map(int, input().split(" "))
ans = 0
Bc = B // C
Bd = B // D

ck = math.gcd(C, D)
asb = C*D/ck
Bs = B//asb

newb = B - Bc - Bd + Bs

Ac = (A-1) // C
Ad = (A-1) // D
As = (A-1)//asb

newa = (A-1)-Ac-Ad+As

print(newb-newa)

def gcd(a,b):
        while b!=0:
                a,b=b,a%b
        return a

A, B, C, D = map(int, input().split(" "))
ans = 0
Bc = B // C
Bd = B // D
ck = 0

asb = C*D//ck
Bs = B//asb

newb = B - Bc - Bd + Bs

Ac = (A-1) // C
Ad = (A-1) // D
As = (A-1)//asb

newa = (A-1)-Ac-Ad+As

print(int(newb-newa))

def gcd(a,b):
        while b!=0:
                a,b=b,a%b
        return a

A, B, C, D = map(int, input().split(" "))
ans = 0
Bc = B // C
Bd = B // D
ck = gcd(C,D)
asb = C*D//ck
Bs = B//asb

newb = B - Bc - Bd + Bs

Ac = (A-1) // C
Ad = (A-1) // D
As = (A-1)//asb

newa = (A-1)-Ac-Ad+As

print(int(newb-newa))

Verdicts: Runtime Error

Runtime Error

Accepted
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):
import math
A, B, C, D = map(int, input().split())
 

lcm = C*D // math.gcd(C, D)
a = B-A+1

if A % C != 0 and B % C != 0: b = a // C
else: b = a // C + 1
if A % D != 0 and B % D != 0: c = a // D
else: c = a // D + 1
if A % lcm != 0 and B % lcm != 0: d = a // lcm
else: d = a // lcm + 1

print(a-b-c+d)



import math
A, B, C, D = map(int, input().split())










lcm = C*D // math.gcd(C, D)
a = B - A + 1
b = B // C - (A-1) // C
c = B // D - (A-1) // D
d = B // lcm - (A-1) // lcm
 
print(a-b-c+d)

Verdicts: Wrong Answer

Accepted
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):
a,b,c,d = map(int,input().split())import math
warareru = b-a+1
x = warareru//c
y = warareru//d
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

 
def lcm(a,b):
    return a*b//gcd(a,b)
z = warareru//lcm(c,d)
print(warareru-(x+y-z))

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

 
def lcm(a,b):
    return a*b//gcd(a,b)

A = (a-1)//c + (a-1)//d - (a-1)//lcm(c,d)
B = b//c + b//d -b//lcm(c,d)

print((b-B)-((a-1)-A))

Verdicts: Runtime Error

Accepted
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):
A,B,C,D=list(map(int,input().split()))
x=max(C,D)
y=min(C,D)
if x%y==0:
    gcd=C*D//y
else:
    while x%y!=0:
        z=x%y
        x=y
        y=z
    gcd=C*D//z
print(B-A+1)

A,B,C,D=list(map(int,input().split()))
x=max(C,D)
y=min(C,D)
if x%y==0:
    gcd=C*D//y
else:
    while x%y!=0:
        z=x%y
        x=y
        y=z
    gcd=C*D//z
print(B-A+1-(B//C-(A-1)//C+B//D-(A-1)//D-B//gcd+(A-1)//gcd))

Verdicts: Wrong Answer

Accepted
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):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D = map(int, input().split())

AC=int(A/C)
AD=int(A/D)
BC=int(B/C)
BD=int(B/D)
ACD=int(A/lcm(C,D))
BCD=int(B/lcm(C,D))
A_=AC+AD-ACD
B_=BC+BD-BCD

print(B-A+1-BC-BD+BCD+AC+AD-ACD)


A,B,C,D = map(int, input().split())

def gcd(c,d):
	if(c==0):
		return d
	else:
		return gcd(d%c,c)
prod = C*D
lcm = prod//gcd(C,D)

AC=int(A/C)
AD=int(A/D)
BC=int(B/C)
BD=int(B/D)
ACD=int(A/lcm)
BCD=int(B/lcm)


print(B-A+1-BC-BD+BCD+AC+AD-ACD)


A,B,C,D = map(int, input().split())

def gcd(c,d):
	if(c==0):
		return d
	else:
		return gcd(d%c,c)
prod = C*D
lcm = prod//gcd(C,D)

AC=int(A/C)
AD=int(A/D)
BC=int(B/C)
BD=int(B/D)
ACD=int(A/lcm)
BCD=int(B/lcm)


print(B-A+1-BC-BD+BCD+AC+AD-ACD)


A,B,C,D = map(int, input().split())

def gcd(c,d):
	if(c==0):
		return d
	else:
		return gcd(d%c,c)
prod = C*D
lcm = prod//gcd(C,D)

A-=1

AC=A//C
AD=A//D
BC=B//C
BD=B//D
ACD=A//lcm
BCD=B//lcm

print(B-A-BC-BD+BCD+AC+AD-ACD)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
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):
import math
A,B,C,D = map(int,input().split())
count = 0
a = (B/C)-(A/C)
b = (B/D)-(A/D)
c = (B/(C*D))-(A/(C*D))

if a > 1:
  a = math.ceil(a)
else:
  a = 0
if b > 1:
  b = math.ceil(b)
else:
  b = 0
if c > 1:
  c = math.ceil(c)
else:
  c = 0
if A%C == 0 and B%C == 0:
  a += 1
if A%D == 0 and B%D == 0:
  b += 1
if A%(C*D) ==0 and B%(C*D) == 0:
  c += 1

ans = B-A+1 - (a+b-c)
print(ans)

import math
A,B,C,D = map(int,input().split())
count = 0
x = math.ceil((B/C)-(A/C))
y = math.ceil((B/D)-(A/D))
z = math.ceil((B/(C*D))-(A/(C*D)))

if A%C == 0:
  x += 1
if A%D == 0:
  y += 1
if A%(C*D) ==0:
  z += 1

ans = B-A+1 -(x+y-z)
print(ans)

import math
def gcd(a,b):
  if a < b:
     a,b = b,a
  c = a%b
  if c == 0:
    return b
  return gcd(b,c)

A,B,C,D = map(int,input().split())
x = gcd(C,D)
count = 0
x = int(C*D/x)
a = (B//C)-((A-1)//C)
b = (B//D)-((A-1)//D)
c = (B//x)-((A-1)//x)
ans = B-A+1 - (a+b-c)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
import math
import fractions


def count_multiple(A, B, x):
    min_value = math.ceil(A / x)
    max_value = B // x
    
    return max_value - min_value + 1


A, B, C, D = [int(i) for i in input().split()]

lcm = C * D // fractions.gcd(C, D)
cnt = 0
for i, x in enumerate([C, D, lcm]):
    if i < 2:
        cnt += count_multiple(A, B, x)
    else:
        cnt -= count_multiple(A, B, x)

total = B - A + 1
ans = total - cnt
print(ans)

#import math

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def count_multiple(A, B, x):
    
    min_value = (A - 1) // x
    max_value = B // x
    
    return max_value - min_value


A, B, C, D = [int(i) for i in input().split()]

# lcm = C * D // math.gcd(C, D)
lcm = C * D // gcd(C, D)
cnt = 0
for i, x in enumerate([C, D, lcm]):
    if i < 2:
        cnt += count_multiple(A, B, x)
    else:
        cnt -= count_multiple(A, B, x)

total = B - (A - 1)
ans = total - cnt
print(ans)

Verdicts: Wrong Answer

Accepted
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):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-09-03 20:30:23 +0900
# LastModified: 2020-09-03 20:48:14 +0900
#


import os
import sys
# import numpy as np



def gcd(a, b):
    while a % b != 0:
        r = a % b
        a = b
        b = r
    return b


def main():
    a, b, c, d = map(int, input().split())
    if (a/c).is_integer():
        c_cnt = (b-a)//c + 1
    else:
        c_cnt = (b-a)//c
    if (a/d).is_integer():
        d_cnt = (b-a)//d + 1
    else:
        d_cnt = (b-a)//d

    lcm = c * d // gcd(max(c, d), min(c, d))
    if (a/lcm).is_integer():
        lcm_cnt = (b-a)//lcm + 1
    else:
        lcm_cnt = (b-a)//lcm
    print(b-a-c_cnt-d_cnt+lcm_cnt)


if __name__ == "__main__":
    main()


#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-09-03 20:30:23 +0900
# LastModified: 2020-09-03 21:14:03 +0900
#


import os
import sys
# import numpy as np



def gcd(a, b):
    while a % b != 0:
        r = a % b
        a = b
        b = r
    return b


def main():
    a, b, c, d = map(int, input().split())
    if (a/c).is_integer():
        c_cnt = b//c - a//c + 1
#        print(b//c, a//c)
    else:
        c_cnt = b//c - a//c
#        print(b//c, a//c)
    if (a/d).is_integer():
        d_cnt = b//d - a//d + 1
#        print(b//d, a//d)
    else:
        d_cnt = b//d - a//d
#        print(b//d, a//d)

    lcm = c * d // gcd(max(c, d), min(c, d))
    if (a/lcm).is_integer():
        lcm_cnt = b//lcm - a//lcm + 1
    else:
        lcm_cnt = b//lcm - a//lcm
#    print(c_cnt, d_cnt, lcm_cnt)
    print(b-a+1-c_cnt-d_cnt+lcm_cnt)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
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):
A,B,C,D = (int(i) for i in input().split())

hogeb = B // D
hogec = B // C
hogebc = B // (D * C)

hoge = hogeb + hogec -hogebc

ononb = A // D
ononc = A // C
ononbc = A // (D * C)

onon = ononb + ononc - ononbc

print(hoge-onon)

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(a,b):
  return a*b//gcd(a,b)

A,B,C,D = (int(i) for i in input().split())

hogeb = B // D
hogec = B // C
hogebc = B // lcm(D,C)

hoge = B-(hogeb + hogec -hogebc)

ononb = (A-1) // D
ononc = (A-1) // C
ononbc = (A-1) // lcm(D,C)

onon = A-1-(ononb + ononc - ononbc)

print(hoge-onon)

Verdicts: Wrong Answer

Accepted