Problem:


Score : 400 points

Problem Statement

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.

Constraints

All values in input are integers.

1 \leq N \leq 10^{12}

Input

Input is given from Standard Input in the following format:

N

Output

Print the maximum number of times the operation can be applied.

Sample Input 1

24

Sample Output 1

3

We can apply the operation three times by, for example, making the following choices:

Choose z=2 (=2^1). (Now we have N=12.)

Choose z=3 (=3^1). (Now we have N=4.)

Choose z=4 (=2^2). (Now we have N=1.)

Sample Input 2

1

Sample Output 2

0

We cannot apply the operation at all.

Sample Input 3

64

Sample Output 3

3

We can apply the operation three times by, for example, making the following choices:

Choose z=2 (=2^1). (Now we have N=32.)

Choose z=4 (=2^2). (Now we have N=8.)

Choose z=8 (=2^3). (Now we have N=1.)

Sample Input 4

1000000007

Sample Output 4

1

We can apply the operation once by, for example, making the following choice:

z=1000000007 (=1000000007^1). (Now we have N=1.)

Sample Input 5

997764507000

Sample Output 5

7



Sample input:
24


Sample output:
3

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)


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

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

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

    return arr


elements = set()


def decomposition(used_set, last_used, rest):
    global elements

    if rest == 0:
        if len(used_set) > len(elements):
            elements = used_set
    i = last_used + 1
    while rest - i >= 0:
        if i in used_set:
            continue
        decomposition(used_set | {i}, i, rest - i)
        i += 1


N = int(input())
if N == 1:
    print(0)
    exit()
factors = factorization(N)
ans = 0
for p, e in factors:
    if e == 2:
        ans += 1
    else:
        elements = set()
        decomposition({1}, 1, e - 1)
        ans += len(elements)
print(ans)

Submission status: Accepted

Solution code:
from decimal import Decimal as de
n=int(input())
def factorization(n):
    factor=[]
    p=[]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            factor.append(i)
            p.append(cnt)
    if temp!=1:
        factor.append(temp)
        p.append(1)
    if len(factor)==0:
        factor.append(n)
        p.append(1)
    return factor,p

ans=0
for i in [k for j,k in zip(factorization(n)[0],factorization(n)[1]) if j!=1]:
  ans+=((de(1)+de(8)*de(i))**de('0.5')-de(1))//de(2)
print(int(ans))

Submission status: Accepted

Solution code:
import sys
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

#print(factorization(24)) #[[2, 3], [3, 1]]

N=int(input())
if N==1:
    print(0)
    sys.exit()
A=factorization(N)
#print(A)
ans=0
for i in range(len(A)):
    p=0
    res=A[i][1]
    while res-p>0:
        p+=1
        res-=p
    #print(p)
    ans+=p
print(ans)

Submission status: Accepted

Solution code:
import sys
n=int(input())
if n==1:
  print(0)
  sys.exit()

#まず素数かどうか判定し、素数でない時に使う
import collections
def prime_fact(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a

c=collections.Counter(prime_fact(n))
d=list(c.items())
num=0
for i in range(len(d)):
  z=int(d[i][1])
  j=1
  while z>=0:
    z=z-j
    j+=1
    if z<0:
      break
    else:
      num+=1
print(num)

Submission status: Accepted

Solution code:
import sys
from bisect import bisect_left, bisect_right
N=int(sys.stdin.readline().strip())

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

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

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

    return arr

F=factorization(N)

L=[1]
for i in range(2,51):
    L.append(L[-1]+i)

ans=0
for x,y in F:
    if x==1: continue
    ans+=bisect_right(L,y)
print ans

Submission status: Accepted

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

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

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

    return arr

n = int(input())
l = factorization(n)
ans = 0
for c in l:
    if c[0]==1:
        break
    lim = c[1]
    num = 1
    while lim >= num:
        lim -= num
        num += 1
    ans += num-1

print(ans)

Submission status: Accepted

Solution code:
import sys
def factoring(n):
    if n == 0:
        return {0: 1}
    if n == 1:
        return {1: 1}
    nOrigin = n
    n = n**0.5
    numlist = [0 for i in range(int(n) + 1)]
    numlist[0] = -1
    numlist[1] = -1

    t = 2
    while t < (n**0.5):
        if numlist[t] == 0:
            numlist[t] = t
            k = 2
            while t * k <= n:
                numlist[t * k] = -1
                k += 1
        t += 1
    while t <= n:
        if numlist[t] == 0:
            numlist[t] = t
        t += 1

    result = {}
    for i in numlist:
        if i == -1:
            continue
        j = 0
        while nOrigin % i == 0:
            j += 1
            nOrigin = nOrigin / i
        if j == 0:
            continue
        else:
            result[i] = j

    if int(nOrigin) != 1:
        result[int(nOrigin)] = 1
    return result

def help(e):
    i=0
    while i*(i+1)//2<=e:
        i+=1
    return i-1


N=int(input())
if N==1:
    print(0)
    sys.exit(0)
d=factoring(N)

retval=0
for key,value in d.items():
    retval+=help(value)


print(retval)

Submission status: Accepted

Solution code:
N = int(input())




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

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

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

    return arr


## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1

def ruisekiwa(n):
	if n<3:
		return 1
	elif n<6:
		return 2
	elif n<10:
		return 3
	elif n<15:
		return 4
	elif n<21:
		return 5
	elif n<28:
		return 6
	elif n<36:
		return 7
	else:
		return 8


a=factorization(N)
ans=0
#print(a)

for insu in a:
	#print(insu[1])
	#print(ruisekiwa(insu[1]))
	ans+=ruisekiwa(insu[1])

if N==1:
	print(0)
else:
	print(ans)




# 2darray [[0] * 4 for i in range(3)]

Submission status: Accepted

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections

a=int(input())
cc=collections.Counter(prime_factorize(a))
cc=cc.values()
ans=0
for k in cc:
    j=1
    while k>=0:
        k=k-j
        ans+=1
        j+=1
    ans=ans-1
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

ps = []
while n % 2 == 0:
    ps.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        ps.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    ps.append(n)

ans = 0
for p, x in Counter(ps).items():
    i = 1
    j = 1
    if x != 1:
        while i <= x:
            j += 1
            i += j
        ans += j-1
    else:
        ans += 1

print(ans)

Submission status: Accepted

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

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

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

    return arr

n = int(input())
if n == 1:
	print(0)
	exit()
l = factorization(n)

ans = 0
for i in range(len(l)):
	num = l[i][1]
	tmp = 1
	count = 0
	while True:
		if num < 0:
			ans += count - 1
			break
		num -= tmp
		tmp += 1
		count += 1
print(ans)

Submission status: Accepted

Solution code:
import collections
import math
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
n = int(input())
c = collections.Counter(prime_factorize(n))
d = list(c.values())
number = 0
for i in range(len(d)):
    number += math.floor((-1 + math.sqrt(1 + 8*d[i]))/2)
print(number)

Submission status: Accepted

Solution code:
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def how_many_times(p):
    i = 0
    while True:
        if i * (i + 1) // 2 > p:
            break
        i += 1

    return i - 1


n = int(input())
factors = Counter(prime_factorize(n))

ans = 0
for f, p in factors.items():
    ans += how_many_times(p)

print(ans)

Submission status: Accepted

Solution code:
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
c = collections.Counter(prime_factorize(n))
ans = 0
for p_num in c.values():
    i = 0
    tmp = 0
    while True:
        i += 1
        tmp += i
        if p_num < tmp:
            break
    ans += i - 1
print (ans)

Submission status: Accepted

Solution code:
from sys import stdin
import math

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

    return arr


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    N_fac = factorization(N)
    cnt = 0
    if N == 1:
        pass
    else:
        for fac,power in N_fac:
            for i in range(power+10):
                if i*(i+1)/2 > power:
                    i -= 1
                    cnt += i
                    break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

    return arr

N = int(input())
prime_factors = factorization(N)
if prime_factors[0][0] == 1:
    print(0)
else:
    ans = 0
    for pf in prime_factors:
        n = pf[1]
        i = 0
        while n >= i:
            n -= i
            i += 1
        ans += i-1
    print(ans)

Submission status: Accepted

Solution code:
def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


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

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

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

    return arr


def main():
    n = int(input())
    divs = sorted(divisor(n))
    ans = 0
    for div in divs[1:]:
        if n % div == 0 and len(factorization(div)) == 1:
            n /= div
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

def prime(n):
    a = 2
    res = []
    while (a * a <= n):
        if (n % a != 0):
            a += 1
            continue
        ex = 0

        while (n % a == 0):
            ex += 1
            n //= a

        res.append([a, ex])

    if (n != 1):
        res.append([n, 1])
    return res

n = int(input())
p = prime(n)

ans = 0
for i in p:
    count = 0
    for j in range(i[1]):
        ans += 1
        count += 1
        i[1] -= count
        if count >= i[1]:
            break

print(ans)

Submission status: Accepted

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


def prime_factors(n):
    factors = set()

    for i in range(2, int(math.sqrt(n+1)+1)):
        while n % i == 0:
            factors.add(i)
            n = int(n/i)
    if n >= 2:
        factors.add(n)
    return factors


n = inp()

fac = prime_factors(n)
res = 0
for f in fac:
    i = 1
    while n % f**i == 0:
        res += 1
        #print(f**i, n)
        n = n // (f**i)

        i += 1
print(res)

Submission status: Accepted

Solution code:
N = int(input())


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

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

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

    return arr


factors = factorization(N)
l = []
for factor in factors:
    for i in range(factor[1]):
        l.append(factor[0]**(i + 1))
l.sort()

ans = 0
for val in l:
    if N == 1:
        break

    if N % val == 0:
        N /= val
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
# D

N = int(input())
# import sympy
# factors = sympy.factorint(N)

# https://note.nkmk.me/python-prime-factorization/
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
factors = dict(collections.Counter(prime_factorize(N)))

num = 0
for f in factors.keys():
    size = 1
    while factors[f] >= size:
        factors[f] -= size
        num += 1
        size += 1

print(num)

Submission status: Accepted

Solution code:
import collections
def pf(N):
    res = []
    x = N
    y = 2
    while y*y <= x:
        while x % y == 0:
            res.append(y)
            x //= y
        y += 1
    if x > 1:
        res.append(x)
    return res

cnt = collections.Counter(pf(int(input())))
ans = 0
for x in cnt:
    tmp = 1
    while cnt[x] > 0:
        cnt[x] -= tmp
        if cnt[x] < 0:
            break
        tmp += 1
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import collections

n = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


ans = 0
if n > 1:
    tmp = collections.Counter(prime_factorize(n))
    for v in tmp.values():
        i = 1
        while v > 0:
            if v - i >= 0:
                v -= i
                ans += 1
                i += 1
            else:
                break
print(ans)

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
from collections import defaultdict

N = int(input())

def primeFactorization(N):
    primes = defaultdict(int)
    R = int(N**(0.5)) + 1
    for num in range(2, R):
        while N % num == 0:
            N //= num
            primes[num] += 1
    if N > 1 :
        primes[N] = 1
    return primes

primes = primeFactorization(N).keys()

que = []
for p in primes:
    heappush(que, (p, p))

ans = 0
while que and N > 0:
    z, p = heappop(que)
    if N % z == 0:
        ans += 1
        N //= z

        heappush(que, (z * p, p))

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

    return arr


f = factorization(N)
total = 0
for c in f:
    if c[0] == 1:
        continue
    target = c[1]
    cnt = 0
    for i in range(1, c[1] + 1):
        target -= i
        if target < 0:
            break
        cnt += 1
    total += cnt

print(total)

Submission status: Accepted

Solution code:

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

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

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

  return arr

def main():
  n = int(input())
  lst = factorization(n)

  ans = 0
  for a, b in lst:
    if a == 1:
      continue

    i = 1
    while i <= b:
      b -= i
      i += 1
      ans += 1

  print(ans)

main()

Submission status: Accepted

Solution code:
n=int(input())
b=[1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8]

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

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

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

    return arr
a=factorization(n)
s=0
if n==1:
    print(0)
else:
    for i in range(len(a)):
        s+=b[a[i][1]-1]
    print(s)

Submission status: Accepted

Solution code:
n = int(input())
d = []
c = 0
while n % 2 == 0:
    c += 1
    n //= 2
if c > 0:
    d.append(c)
p = 3
while p*p <= n:
    c = 0
    while n % p == 0:
        c += 1
        n //= p
    if c > 0:
        d.append(c)
    p += 2
if n > 1:
    d.append(1)
ans = 0
for x in d:
    c = 1
    while x >= c:
        ans += 1
        x -= c
        c += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
d=dict()
for i in range(1,int(n**0.5)+1):
    cnt=0
    while n%(i+1)==0:
        n//=i+1
        cnt+=1
    d[i+1]=cnt
if n>1:
    if n in d:
        d[n]+=1
    else:
        d[n]=1
ans=0
d=list(d.items())
for i,r in d:
    for j in range(1,44):
        if j*(j+1)//2>r:
            ans+=j-1
            break
print(ans)

Submission status: Accepted

Solution code:
def prime_factorizarion(n):
	arr = []
	temp = n
	for i in range(2, int(n**0.5)+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp//=i
			arr.append([i,cnt])
	
	if temp!=1:
		arr.append([temp,1])
	
	if arr==[]:
		arr.append([n,1])
	
	return arr

N=int(input())
if N==1:
    print(0)
    exit()
primes=prime_factorizarion(N)

ans=0
for prime,count in primes:
    cnt=1
    tmp=1
    while True:
        if tmp>count:
            break
        ans+=1
        cnt+=1
        tmp+=cnt
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
pf = {}

for i in range(2, int(n**0.5) + 1):
    while not n % i:
        pf[i] = pf.get(i, 0) + 1
        n //= i
if n > 1:
    pf[n] = 1
#print(pf)

cnt = 0
for i in pf.values():
    for j in range(1, 50):
        if i - j >= 0:
            cnt += 1
            i -= j
        else:
            break
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
if n==1:
    print(0)
else:
    lst=[]
    i=2
    while i**2<=n:
        if n%i==0:
            n//=i
            lst.append(i)
            continue
        i+=1
    lst.append(n)
    from collections import Counter
    dic=dict(Counter(lst))
    s=0
    for i in dic:
        n=dic[i]
        k=0
        while n>=0:
            s+=1
            k+=1
            n-=k
        s-=1
    print(s)

Submission status: Accepted

Solution code:
from math import floor,sqrt
def prime(n):
    a = []
    d={}
    while n % 2 == 0:
        try:
            d[2]+=1
        except:
            d[2]=1
            a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            try:
                d[f]+=1
            except:
                d[f]=1
                a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        try:
            d[n]+=1
        except:
            d[n]=1
            a.append(n)
    return a,d
n=int(input())
a,d=prime(n)
ans=0
for i in range(len(a)):
    k=floor(sqrt(2*d[a[i]]))
    if k*(k+1)//2>d[a[i]]:
        k-=1
    ans+=k
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

pf = {}

for i in range(2,int(n**0.5)+1):
    while n % i == 0:
        pf[i] = pf.get(i,0) + 1
        n //= i
if n > 1: pf[n] = 1

ans = 0

for v in pf.values():
    
    l = 1; r = v # 二分探索時は探索範囲は取り得る値+-1しておく

    while l+1 < r:
        c = (l+r)//2
        if c*(c+1)/2 <= v:
            l = c
        else:
            r = c
    ans += l

print(ans)

Submission status: Accepted

Solution code:
import collections

def prime_factorize(x):
    factor = []
    while x % 2 == 0:
        x //= 2
        factor.append(2)
    div = 3
    while div ** 2 <= x:
        if x % div == 0:
            x //= div
            factor.append(div)
        else:
            div += 2
    if x != 1:
        factor.append(x)
    return collections.Counter(factor)

n = int(input())
ans = 0
for x in prime_factorize(n).values():
    tmp = 0
    check = 1
    i = 2
    while check <= x:
        check += i
        tmp += 1
        i += 1
    ans += tmp
print(ans)

Submission status: Accepted

Solution code:
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

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

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

    return arr

N = int(input())
fac = []
fac = factorization(N)

#print(fac)

def sankaku(x):
    ans = 0
    for i in range(int(2*math.sqrt(x))):
        if i*(i+1)//2 < x:
            ans += 1
        else:
            pass
    return ans

def truesan(x):
    return sankaku(x+1)-1

#print(truesan(N))

a = 0
for i in range(len(fac)):
    a += truesan(fac[i][1])

print(a if N != 1 else 0)

Submission status: Accepted

Solution code:
import sys
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def prime_list(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f


def return_N(n):
    prob = math.floor(math.sqrt(2*n))
    if (prob -1 ) * (prob ) <= 2*n < (prob + 1) * (prob):
        return  prob -1
    elif (prob -2 ) * (prob -1) <= 2*n < (prob -1) * (prob):
        return prob - 2
    elif (prob) * (prob + 1) <= 2*n < (prob + 1) * (prob +2):
        return prob

    
    
N = int(readline())
PP = prime_list(N)
ans = 0 
for i in range(len(PP)):
    ans += return_N(PP[i][1])
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def div_count(primes: dict) -> int:
    cnt = 0
    for _, c in primes.items():
        i = 1
        while True:
            if c < i:
                break
            cnt += 1
            c -= i
            i += 1

    return cnt


if __name__ == "__main__":
    n = int(input())
    primes = Counter(prime_factorize(n))
    print(div_count(primes))

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math
import random
from decimal import Decimal
import itertools
import re
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(2147483647)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

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

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

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

    return arr


def main():
	n = I()
	factos = factorization(n)
	count = 0
	for num, facto in factos:
		sum_tmp = 0
		for i in range(1,facto+1):
			sum_tmp += i
			if sum_tmp <= facto:
				count += 1
	if n == 1:
		print(0)
	else:
		print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())
c = collections.Counter(prime_factorize(n))
# Counter({2: 3, 3: 1, 5: 1, 7: 1})

count = 0
for k, v in c.items():
    sum = 0
    for i in range(1, 10 ** 10):
        sum += i
        if sum > v:
            break
        count += 1
print(count)

Submission status: Accepted

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

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

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

    return arr

num = int(input())
val = factorization(num)
ans = 0
for x in val:
    if x[0] == 1: break
    val = 0
    for i in range(40):
        val += i + 1
        if x[1] < val:
            ans += i
            break
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
a = []
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)

c = Counter(a)
ans = 0
loop = True
for i in c.values():
    x = 1
    while loop == True:
        if x * (x + 1) // 2 <= i < (x + 1) * (x + 2) // 2:
            break
        x += 1
    ans += x
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import accumulate


def prime_factorize(n):
    """素因数分解し，ユニークな素因数のsetを返す。"""
    ans = []
    ans_add = ans.append
    while n % 2 == 0:
        ans_add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans_add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans_add(n)
    return ans


def main():
    n = int(input())
    primes = prime_factorize(n)
    acc = tuple(accumulate(range(1, 42)))
    counted = Counter(primes)
    ans = 0

    for c in counted.values():
        for i, x in enumerate(acc):
            if c >= x:
                tmp = i + 1
            else:
                break
        ans += tmp

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections


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

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

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

    if arr[0] == [1, 1]:
        return []

    return arr


n = int(input())
fact_list = factorization(n)

# print(fact_list)
ans = 0
for num, exp in fact_list:

    for i in range(1, exp+1):
        if exp-i >= 0:
            ans += 1
            exp -= i
        else:
            break

print(ans)

Submission status: Accepted

Solution code:
import math




def solve(n):
    ans = 0
    for i in range(2, int(math.sqrt(n) + 2)):
        if n % i == 0:
            times = 0
            needed = 1
            while n % i ==0:
                times += 1
                if times>= needed:
                    times = 0
                    needed += 1
                    ans += 1
                n //= i
    if not n == 1:
        print(ans+1)
    else:
        print(ans)
    return



n = int(input())
solve(n)