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()))
def euqlid(x,y):
    if x < y :
        temp = x
        x = y
        y = temp
    while x % y != 0:
        temp = x
        x = y
        y = temp % y
    return y
def searchCount(p,q,k):
    min = 0
    max = 0
    if a % k == 0:
        min = p
    else:
        min = p//k + 1
    max = q//k
    return int(max - min) + 1
lcm = euqlid(c,d)
gcd = c * d / lcm
print((b - a + 1) - searchCount(a,b,c) - searchCount(a,b,d) + searchCount(a,b,gcd))

a, b, c, d = list(map(int, input().split()))
def nearUpNum (num, div):
    if num % div == 0:
        return num
    else:
        return num - num % div

def nearDownNum(num, div):
    if num % div == 0:
        return num
    else:
        return num + (div - num % div)

def euqlid(x,y):
    if x < y :
        temp = x
        x = y
        y = temp
    while x % y != 0:
        temp = x
        x = y
        y = temp % y
    return y
n = (c * d) / euqlid(c,d)
C = (((nearUpNum(b,c) - nearDownNum(a,c)) / c) + 1)
D = (((nearUpNum(b,d) - nearDownNum(a,d)) / d) + 1)
CandD = (((nearUpNum(b, n) - nearDownNum(a, n)) / n) + 1)
print("C =>  {}:D =>  {}:CandD => {}".format(C,D,CandD))
print(int((b - a + 1) - (C + D - CandD)))

a, b, c, d = list(map(int, input().split()))
def euqlid(x,y):
    if x < y :
        temp = x
        x = y
        y = temp
    while x % y != 0:
        temp = x
        x = y
        y = temp % y
    return y
def searchCount(p,q,k):
    min = 0
    max = 0
    if a % k == 0:
        min = p
    else:
        min = p//k + 1
    max = q//k
    return int(max - min) + 1
lcm = euqlid(c,d)
gcd = int(c * d / lcm)
print((b - a + 1) - searchCount(a,b,c) - searchCount(a,b,d) + searchCount(a,b,gcd))

a, b, c, d = list(map(int, input().split()))
def divNumCount(start, end, div):
    count = 0
    num = 0
    i = start
    while i <= end:
        if i % div == 0:
            i += div - 1
            count += 1
        i += 1
    return count
def euqlid(a,b):
    if a < b:
        temp = a
        a = b
        b = temp
    while(a % b != 0):
        temp = a % b
        a = b
        b = temp
    return b

C = 0
D = 0
CandD = 0
C = divNumCount(a, b, c)
D = divNumCount(a, b, d)
CandD = divNumCount(a, b, c * d / euqlid(c,d))
print("C => {} D => {} CandD => {}".format(C, D, CandD))
print(b - a + 1 - (C + D - CandD))

a, b, c, d = list(map(int, input().split()))
def euqlid(x,y):
    if x < y :
        temp = x
        x = y
        y = temp
    while x % y != 0:
        temp = x
        x = y
        y = temp % y
    return y
def searchCount(a,b,k):
    min = 0
    max = 0
    if a % k == 0:
        min = a
    else:
        min = int(a/k) + 1
    max = int(b/k)
    return int(max - min) + 1

lcm = euqlid(c,d)
gcd = c * d / lcm
print((b - a + 1) - searchCount(a,b,c) - searchCount(a,b,d) + searchCount(a,b,gcd))

a, b, c, d = list(map(int, input().split()))
def euqlid(x,y):
    if x < y :
        temp = x
        x = y
        y = temp
    while x % y != 0:
        temp = x
        x = y
        y = temp % y
    return y
def searchCount(p,q,k):
    min = 0
    max = 0
    if p % k == 0:
        min = p // k
    else:
        min = p//k + 1
    max = q//k
    return max - min + 1
lcm = euqlid(c,d)
gcd = int((c * d) / lcm)
print((b - a + 1) - searchCount(a,b,c) - searchCount(a,b,d) + searchCount(a,b,gcd))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted