Problem p02900 (python)

Fixed submission:
import math
import fractions
gcd = math.gcd if hasattr(math, "gcd") else fractions.gcd

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

g = gcd(A, B)

print(len(set(factorize(g)))+1)

Buggy submission (verdict: Runtime Error):
import math
import fractions
gcd = math.gcd

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

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

g = gcd(A, B)

print(len(set(factorize(g)))+1)

Buggy submission (verdict: Runtime Error):
import math

def factorization(n):
    div = 2
    fct = []
    while div * div <= n:
        while n % div == 0:
            n //= div
            fct.append(div)
        div += 1
    if n > 1:
        fct.append(n)
    return fct

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = set(factorization(gcd))
    print(len(facts) + 1)

Buggy submission (verdict: Runtime Error):
import math

def factorization(n):
    arr = []
    tmp = n
    for div in range(2, int(-(-n**0.5//1))+1):
        if tmp % div == 0:
            cnt = 0
            while tmp % div == 0:
                cnt += 1
                tmp //= div
            arr.append([div, cnt])

    if tmp != 1:
        arr.append([tmp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = factorization(gcd)
    print(len(facts) + 1)

Buggy submission (verdict: Runtime Error):
import math

def factorization(n):
    arr = []
    tmp = n
    for div in range(2, int(-(-n**0.5//1))+1):
        if tmp % div == 0:
            cnt = 0
            while tmp % div == 0:
                cnt += 1
                tmp //= div
            arr.append([div, cnt])

    if tmp != 1:
        arr.append([tmp, 1])

    if len(arr) == 0:
        arr.append([n, 1])

    return arr

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = factorization(gcd)
    print(len(facts) + 1)

Buggy submission (verdict: Runtime Error):
import math

def factorization(n):
    arr = []
    tmp = n
    for div in range(2, int(math.sqrt(n)) + 2):
        if tmp % div == 0:
            cnt = 0
            while tmp % div == 0:
                cnt += 1
                tmp //= div
            arr.append([div, cnt])

    if tmp != 1:
        arr.append([tmp, 1])

    if len(arr) == 0:
        arr.append([n, 1])

    return arr

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = factorization(gcd)
    print(len(facts) + 1)

Buggy submission (verdict: Runtime Error):
import math

def factorization(n):
    arr = []
    tmp = n
    for div in range(2, int(math.sqrt(n))+1):
        if tmp % div == 0:
            cnt = 0
            while tmp % div == 0:
                cnt += 1
                tmp //= div
            arr.append([div, cnt])

    if tmp != 1:
        arr.append([tmp, 1])

    if len(arr) == 0:
        arr.append([n, 1])

    return arr

if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = factorization(gcd)
    print(len(facts) + 1)

Buggy submission (verdict: Runtime Error):
import math

def prime_factorize(n):
    ret = []
    while n % 2 == 0:
        ret.append(2)
        n //= 2
    div = 3
    while div <= math.sqrt(n):
        if n % div == 0:
            ret.append(div)
            n //= div
        else:
            div += 2
    if n != 1:
        ret.append(n)
    return ret


if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = prime_factorize(gcd)
    print(len(facts) + 1)

Buggy submission (verdict: Runtime Error):
import math

def prime_factorize(n):
    ret = []
    while n % 2 == 0:
        ret.append(2)
        n //= 2
    div = 3
    while div <= math.sqrt(n):
        if n % div == 0:
            ret.append(div)
            n //= div
        else:
            div += 2
    if n != 1:
        ret.append(n)
    return ret


if __name__ == '__main__':
    A, B = map(int, input().split())
    gcd = math.gcd(A, B)
    if gcd == 1:
        print(1)
        exit()
    facts = set(prime_factorize(gcd))
    print(len(facts) + 1)