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):
nums = input()
intNums = []

def saidaiKouYaku(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp

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


for n in nums.split():
    intNums.append(int(n))
    
if len(intNums) == 4 and intNums[0] <= intNums[1] \
    and (intNums[0] >= 1 and intNums[0] <= 10**18) \
    and (intNums[1] >= 1 and intNums[1] <= 10**18) \
    and (intNums[2] >= 1 and intNums[2] <= 10**9) \
    and (intNums[3] >= 1 and intNums[3] <= 10**9):

    
    
    saidaiKouYaku = saidaiKouYaku(intNums[2], intNums[3])
    
    
    saisyoKoubai = intNums[2] * intNums[3] // saidaiKouYaku
#     print('saidaiKouYaku = ',saidaiKouYaku)

    c1 = intNums[1] // intNums[2] - intNums[0] // intNums[2]
    c2 = intNums[1] // intNums[3] - intNums[0] // intNums[3]
    c3 = intNums[1] // saisyoKoubai - intNums[0] // saisyoKoubai
#     print(c1)
#     print(c2)
#     print(c3)
    c4 = c1 + c2 - c3
    result = (intNums[1] - (intNums[0]-1)) - c4
    print(result)


nums = input()
intNums = []
for n in nums.split():
    intNums.append(int(n))

if len(intNums) == 4 and intNums[0] <= intNums[1] \
    and (intNums[0] >= 1 and intNums[0] <= 10**18) \
    and (intNums[1] >= 1 and intNums[1] <= 10**18) \
    and (intNums[2] >= 1 and intNums[2] <= 10**9) \
    and (intNums[3] >= 1 and intNums[3] <= 10**9):

    
    c1 = intNums[1] // intNums[2] - intNums[0] // intNums[2]
    c2 = intNums[1] // intNums[3] - intNums[0] // intNums[3]
    c3 = intNums[1] // (intNums[2]*intNums[3]) - intNums[0] // (intNums[2]*intNums[3])
#     print(c1)
#     print(c2)
#     print(c3)
    c4 = c1 + c2 - c3
    result = (intNums[1] - (intNums[0]-1)) - c4
    print(result)

nums = input()
intNums = []

def saidaiKouYaku(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    while(r != 0):
        a = b
        b = r
        r = a % b
    return b


for n in nums.split():
    intNums.append(int(n))
    
if len(intNums) == 4 and intNums[0] <= intNums[1] \
    and (intNums[0] >= 1 and intNums[0] <= 10**18) \
    and (intNums[1] >= 1 and intNums[1] <= 10**18) \
    and (intNums[2] >= 1 and intNums[2] <= 10**9) \
    and (intNums[3] >= 1 and intNums[3] <= 10**9):

    
    
    saidaiKouYaku = saidaiKouYaku(intNums[2], intNums[3])
    
    
    saisyoKoubai = intNums[2] * intNums[3] // saidaiKouYaku
#     print('saidaiKouYaku = ',saidaiKouYaku)

    c1 = intNums[1] // intNums[2] - intNums[0] // intNums[2]
    c2 = intNums[1] // intNums[3] - intNums[0] // intNums[3]
    c3 = intNums[1] // saisyoKoubai - intNums[0] // saisyoKoubai
#     print(c1)
#     print(c2)
#     print(c3)
    c4 = c1 + c2 - c3
    result = (intNums[1] - (intNums[0]-1)) - c4
    print(result)
    

                

nums = input()
intNums = []

def saidaiKouYaku(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp

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


for n in nums.split():
    intNums.append(int(n))
    
if len(intNums) == 4 and intNums[0] <= intNums[1] \
    and (intNums[0] >= 1 and intNums[0] <= 10**18) \
    and (intNums[1] >= 1 and intNums[1] <= 10**18) \
    and (intNums[2] >= 1 and intNums[2] <= 10**9) \
    and (intNums[3] >= 1 and intNums[3] <= 10**9):

    
    
    saidaiKouYaku = saidaiKouYaku(intNums[2], intNums[3])
    
    
    saisyoKoubai = (intNums[2] * intNums[3]) // saidaiKouYaku
#     print('saidaiKouYaku = ',saidaiKouYaku)

    c1 = intNums[1] // intNums[2] - (intNums[0]-1) // intNums[2]
    c2 = intNums[1] // intNums[3] - (intNums[0]-1) // intNums[3]
    c3 = intNums[1] // saisyoKoubai - (intNums[0]-1) // saisyoKoubai
#     print(c1)
#     print(c2)
#     print(c3)
    c4 = c1 + c2 - c3
    result = (intNums[1] - (intNums[0]-1)) - c4
    print(result)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted