Problem: Given is a positive integer N. Consider repeatedly applying the operation below on N:    * First, choose a positive integer z satisfying all of the conditions below:     * z can be represented as z=p^e, where p is a prime number and e is a positive integer;     * z divides N;     * z is different from all integers chosen in previous operations.   * Then, replace N with N/z.  Find the maximum number of times the operation can be applied.

Submission attempts (in order):
import math
 

def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True
 
def getPrimeExp(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(2, n_sqrt+1):
                ij = i**j
                if ij <= n_sqrt and array[ij]:
                    result.append(ij)
                    array[ij] = False
                elif ij > n:
                    break
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False
 
            # for j in range(2, n):
            
            
            
            
    return sorted(result)
 
N = int(input())
if N == 1:
    print(0)
elif is_prime(N) and N != 1:
    print(1)
else:
    cnt = 0
    primeExp = getPrimeExp(N) 
    n = N
    already = []
    
    for z in primeExp:
        if n%z == 0:
            n = int(n/z)
            cnt += 1
            already.append(z)
    if is_prime(n) and n not in already:
        cnt += 1
    else:
        for a in already:
            if n%a == 0:
                while n%a == 0:
                    n = int(n/a)
        if is_prime(n) and n not in already:
            cnt += 1

    print(cnt)

import math


def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True

def getPrimeExp(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(2, n_sqrt+1):
                ij = i**j
                if ij <= n_sqrt and array[ij]:
                    result.append(ij)
                    array[ij] = False
                elif ij > n:
                    break
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False

            # for j in range(2, n):
            
            
            
            
    return sorted(result, reverse=True)

N = int(input())
if N == 1:
    print(0)
elif is_prime(N) and N != 1:
    print(1)
else:
    cnt = 0
    n = N
    primeExp = getPrimeExp(n) 
    already = []
    
    for z in primeExp:
        if n%z == 0:
            n = int(n/z)
            cnt += 1
            already.append(z)
            # print(z)
            # print(n)
    if is_prime(n):
        cnt += 1
    print(cnt)

import math


def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True

def getPrimeExp(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(2, n_sqrt+1):
                ij = i**j
                if ij <= n_sqrt and array[ij]:
                    result.append(ij)
                    array[ij] = False
                elif ij > n:
                    break
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False

            # for j in range(2, n):
            
            
            
            
    return sorted(result, reverse=True)

N = int(input())
if N == 1:
    print(0)
elif is_prime(N) and N != 1:
    print(1)
else:
    cnt = 0
    n = N
    primeExp = getPrimeExp(n) 
    already = []
    
    for z in primeExp:
        if n%z == 0:
            n = int(n/z)
            cnt += 1
            already.append(z)
            # print(z)
            # print(n)
    if is_prime(n) and n not in already:
        cnt += 1
    print(cnt)

import math


def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True      


def getPrime(n):
    n_sqrt = int(math.sqrt(n))
    array = [True]*(n_sqrt+1)
    result = []
    for i in range(2, n_sqrt+1):
        if array[i]:
            array[i] = False
            result.append(i)
            for j in range(i*2, n_sqrt+1, i):
                array[j] = False
    return result

N = int(input())
n = N
prime = getPrime(n)
prime_exp = []

for p in prime:
    cnt = 0
    while n%p == 0:
        n = int(n/p)
        # print(n)
        cnt += 1
    if cnt != 0:
        prime_exp.append([p, cnt])
if is_prime(n) and n != 1:
    prime_exp.append([n, 1])
ans = 0
for pe in prime_exp:
    ans += int((-1+math.sqrt(1+8*pe[1]))/2)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted