Problem p02900 (python)

Fixed submission:
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])

def factorize(g):
  factor = []
  for i in range(2, int(np.sqrt(g))+2):
    if g % i != 0:
      continue
    while g % i == 0:
      g //= i
    factor.append(i)
  if g != 1:
    factor.append(g)
  return factor
print(len(factorize(g))+1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
max_prime = int(np.sqrt(g))+1
primes = np.ones(g + 1)
#print(g+1, primes.shape)
primes[0] = 0
#print(primes)
for i in range(2, max_prime):
  if i * 2 < g + 1:
    primes[i*2::i] = 0
    #print(i, primes)

primes = primes.nonzero()[0]
#print(primes.nonzero()[0])

factor = primes[g % primes == 0]

#print(g, original_g, factor)
print(len(factor))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
max_prime = int(np.sqrt(g))+1
primes = np.ones(g + 1)
#print(g+1, primes.shape)
primes[0:2] = 0
#print(primes)
for i in range(2, max_prime):
  if i * 2 < g + 1:
    try:
   	  primes[i*2::i] = 0
    except:
      pass
    #print(i, primes)

primes = primes.nonzero()[0]
#print(primes.nonzero()[0])

factor = primes[g % primes == 0]

#print(g, original_g, factor)
print(len(factor) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
max_prime = int(np.sqrt(g))+1
primes = np.ones(g + 1)
#print(g+1, primes.shape)
primes[0:2] = 0
#print(primes)
for i in range(2, max_prime):
  if i * 2 < g + 1:
    primes[i*2::i] = 0
    #print(i, primes)

primes = primes.nonzero()[0]
#print(primes.nonzero()[0])

factor = primes[g % primes == 0]

#print(g, original_g, factor)
print(len(factor) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
max_prime = g + 2
primes = np.ones(max_prime)
#print(g+1, primes.shape)
primes[0:2] = 0
#print(primes)
for i in range(2, int(np.sqrt(max_prime))+2):
  if i * 2 < max_prime:
    primes[i*2::i] = 0
    #print(i, primes)
    
primes = np.arange(max_prime)[primes == 1]
#print(primes)

factor = []
for i in primes:
  if g % i == 0:
    #print(g)
    factor.append(i)

#print(g, factor)
print(len(factor) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
original_g = g
max_prime = g + 2
primes = np.ones(max_prime)
#print(g+1, primes.shape)
primes[0:2] = 0
#print(primes)
for i in range(2, max_prime):
  if i * 2 < max_prime:
    primes[i*2::i] = 0
    #print(i, primes)
    
primes = np.arange(max_prime)[primes == 1]
#print(primes)

factor = []
for i in primes:
  if g % i == 0:
    #print(g)
    factor.append(i)

#print(g, original_g, factor)
print(len(factor) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
original_g = g
max_prime = g + 2
primes = np.ones(max_prime)
#print(g+1, primes.shape)
primes[0:2] = 0
#print(primes)
for i in range(2, max_prime):
  if primes[i] and i * 2 < g + 2:
    primes[i*2::i] = 0
    #print(i, primes)
    
primes = np.arange(max_prime)[primes == 1]
#print(primes)

factor = []
for i in primes:
  if g % i == 0:
    #print(g)
    factor.append(i)

#print(g, original_g, factor)
print(len(factor) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+1)
#print(g+1, primes.shape)
primes[0] = 0
#print(primes)
for i in range(2, int(np.sqrt(g))+1):
  if primes[i] and i * 2 < g + 2:
    primes[i*2::i] = 0
    #print(i, primes)
    
primes = np.arange(g+1)[primes == 1]
#print(primes)

factor = []
for i in primes:
  if g % i == 0:
    g //= i
    factor.append(i)

if g == 1:
  print(len(factor) + 1)
else:
  print(len(factor))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+1)
#print(g+1, primes.shape)
primes[0] = 0
#print(primes)
for i in range(2, int(np.sqrt(g))+1+1):
  if primes[i] and i * 2 < g + 2:
    primes[i*2::i] = 0
    #print(i, primes)
    
primes = np.arange(g+1)[primes == 1]
#print(primes)

factor = []
for i in primes:
  if g % i == 0:
    g //= i
    factor.append(i)

if g != 1:
  print(len(factor) + 1)
else:
  print(len(factor))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+2)
primes[0:2] = 0
for i in range(2, int(np.sqrt(g))+1+1):
  if primes[i] and i * 2 < g + 2:
    primes[i*2::i] = 0

count = 0
for i in range(2,g+1):
  if primes[i] and g%i == 0:
    count += 1
print(count + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+1)
primes[0:2] = 0
for i in range(2, int(math.sqrt(g))+1+1):
  if primes[i] and i * 2 < g + 1:
    primes[i*2::i] = 0

count = 0
for i in range(2,g+1):
  if primes[i] and g%i == 0:
    count += 1
print(count + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+2)
primes[0:2] = 0
for i in range(2, int(math.sqrt(g))+1+1):
  if primes[i]:
    primes[i*2::i] = 0

count = 0
for i in range(2,g+1):
  if primes[i] and g%i == 0:
    count += 1
print(count + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
import math
import numpy as np
N = list(map(int, input().split()))
g = gcd(N[0], N[1])
primes = np.ones(g+1)
primes[0:2] = 0
for i in range(2, int(math.sqrt(g))+1+1):
  if primes[i]:
    primes[i*2::i] = 0

count = 0
for i in range(g+1):
  if primes[i] and g%i == 0:
    count += 1
print(count + 1)