Problem:


Prime Factorization

Factorize a given integer n.

Input

n

An integer n is given in a line.

Output

Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.

Constraints

2 ≤ n ≤ 109

Sample Input 1

12

Sample Output 1

12: 2 2 3

Sample Input 2

126

Sample Output 2

126: 2 3 3 7



Sample input:
12


Sample output:
12: 2 2 3

Submission status: Accepted

Solution code:
import math


def sieve_of_eratosthenes(N):
    prime_list = []
    for i in range(0, N):
        if i * i > N:
            break
        prime_list.append(True)
    prime_list[0] = prime_list[1] = False
    prime = []
    n = len(prime_list)
    for i in range(2, n):
        if prime_list[i]:
            prime.append(i)
            for j in range(2 * i, n, i):
                prime_list[j] = False
    return prime


def cal_count(prime, N):
    for i in range(len(prime)):
        if N < prime[i]:
            break
        while N % prime[i] == 0:
            print('', prime[i], end='')
            N //= prime[i]
    if N != 1:
        print('', N, end='')
    print()


def main():
    N = int(input())
    prime = sieve_of_eratosthenes(N)
    prime.append(N)
    print(N,end='')
    print(':', end='')
    cal_count(prime, N)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

n = int(input())
prime_factorize(n)
print('{}:'.format(n), *prime_factorize(n))

Submission status: Accepted

Solution code:
n = int(input())
F = {}
tmp = n
i = 2
while i**2 <= tmp:
    cnt = 0
    while tmp % i == 0:
        cnt += 1
        tmp //= i
    if cnt > 0:
        F[i] = cnt
    i += 1
if tmp != 1 or F == {}:
    F[tmp] = 1
G = []
for p in F:
    for i in range(F[p]):
        G.append(str(p))
G = ' '.join(G)
print(f'{n}: {G}')

Submission status: Accepted

Solution code:
n=int(input())
P=list()
N=n
y=2
while y*y<=N:
    while N%y==0:
        P.append(y)
        N//=y
    y+=1
if N>1:
    P.append(N)
print(n,":",sep="",end="")
print("",*P,sep=" ")

Submission status: Accepted

Solution code:
def main():
    import sys
    N = int(sys.stdin.readline())
    SN = N
    def calc(N):
        import math
        L = []
        for i in range(2, int(math.sqrt(N))+2):
            while N % i==0:
                L += [i]
                N = N//i
        if N !=1:
            L += [N]
        print(str(SN) + ': ' + ' '.join(map(str,L)))
    
    calc(N)
   

if __name__=='__main__':
    main()

Submission status: Accepted

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

n=int(input())
s=str(n)+':'
arr=factorization(n)
for x,y in arr:
    s+=(' '+str(x))*y
print(s)

Submission status: Accepted

Solution code:
n = int(input())

print(str(n)+': ',end="")

ans=[]

i = 2
while i*i  <= n:
    while n % i == 0:
        n //= i
        ans.append(i)
    i += 1
if n != 1:
    ans.append(n)

print(*ans)

Submission status: Accepted

Solution code:
def prime_factorize(N):
    # 素因数分解
    import math as m
    a = []
    for i in range(2, int(m.sqrt(N)) + 1):
        while N % i == 0:
            a.append(i)
            N //= i
    if N > 1:
        a.append(N)
    return a


def resolve():
    N = int(input())
    a = prime_factorize(N)
    print(str(N) + ":", *a)


resolve()

Submission status: Accepted

Solution code:
def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    if n < 2:
        return [n]

    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes


n = int(input())

print('{}: {}'.format(n, ' '.join(map(str, prime_factorization(n)))))

Submission status: Accepted

Solution code:
import math
def prime_factorize(n):
    i = 2
    factors = []
    while i <= math.floor(n**0.5):
        if n%i == 0:
            factors.append(i)
            n //= i
        else:
            i += 1
    if n>1:
        factors.append(n)
    return factors
N = int(input())
ans = ""
ans += str(N)
ans += ":"
ans += " "
S = prime_factorize(N)
S.sort()
for i in range(len(S)):
    if i == len(S)-1:
        ans += str(S[i])
    else:
        ans += str(S[i])
        ans += " "
print(ans)

Submission status: Accepted

Solution code:

def is_prime(N):
    i = 0
    if N <= 1:
        return False, i
    i = 2
    while i*i <= N:
        if N%i == 0:
            return True, i
        i += 1
    return True, N

N = int(input())
print(str(N)+': ', end='')
ans = []
while True:
    F, i = is_prime(N)
    if F:
        ans.append(i)
        N //= i
    else:
        print(' '.join(map(str, ans)))
        break

Submission status: Accepted

Solution code:
# 素因数分解
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A&lang=ja

import math

n = int(input())
origin = n
ans = []

i = 2
while i <= math.sqrt(n):
    if n % i == 0:
        n //= i
        ans.append(str(i))
    else:
        i += 1

if n != 1:
    ans.append(str(n))

print(f'{origin}: {" ".join(ans)}')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

n = int(input())
print(n, ": ", sep = "", end = "")

pri = []
while n % 2 == 0:
   pri.append(2)
   n //= 2

for i in range(3, int(n ** 0.5 + 1)):
   while n % i == 0:
      pri.append(i)
      n //= i
   i += 2

if n != 1:
   pri.append(n)

for i in range(len(pri)):
   print(pri[i], end = "")
   if i < len(pri) - 1:
      print(" ", end = "")
print("")

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

n = int(input())
def prime_factorize(n):
    prime_fact = []
    while n%2 == 0:
        prime_fact.append(2)
        n//=2
    f = 3
    while f * f <= n:
        if n % f == 0:
            prime_fact.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        prime_fact.append(n)
    return prime_fact
a = prime_factorize(n)
print(str(n)+": ",end = "")
print(*a)

Submission status: Accepted

Solution code:
def Eratosthenes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

n = int(input())
n2 = n

if n < 2:
    print(n)
    exit()

prime_factors = [] #素因数
for i in Eratosthenes(int(n ** 0.5)):
    if i**2 > n2:
        break
    while n2 % i == 0:
        prime_factors.append(i)
        n2 //= i
if n2 > 1:
    prime_factors.append(n2)

ans = [str(i) for i in prime_factors]
ans = " ".join(ans)
print("{}: {}".format(n, ans))

Submission status: Accepted

Solution code:
n = int(input())
n_str = str(n)
res = ''

for i in range(2, int(n//2) + 1):
    if res == '' and i > n**0.5//1:
        res = ' {}'.format(str(n_str))
        break

    while n % i == 0:
        res += ' {}'.format(str(i))
        n //= i

    if n == 1:
        break
print('{}:{}'.format(n_str, res))

Submission status: Accepted

Solution code:
import math

n = int(input())

n_sqrt = int(math.sqrt(n))

i = 1
yaku = []
while i**2<=n:
    if n%i==0:
        yaku.append(i)
        yaku.append(n//i)
    i += 1
yaku = list(set(yaku))
del(yaku[0])

ylen = len(yaku)

sosu = []
Yaku = []
for i in range(ylen):
    
    j = 1
    table = []
    while j**2<=yaku[i]:
        if yaku[i]%j==0:
            table.append(j)
            table.append(yaku[i]//j)
        j += 1
    table = list(sorted(set(table)))
    
    if len(table)==2:
        sosu.append(yaku[i])

for i in range(len(sosu)):
    for j in range(len(sosu)-1,0,-1):
        if sosu[j-1]>sosu[j]:
            sosu[j-1],sosu[j] = sosu[j],sosu[j-1]

Count = []
m = n
for i in range(len(sosu)):
    count = 0
    while True:
        m = m/sosu[i]
        count += 1
        if m%sosu[i]==0:
            pass
        else:
            Count.append(count)
            break

print(n,end='')
print(':',end=' ')
for i in range(len(sosu)):
    for j in range(Count[i]):
        if i==len(sosu)-1 and j==Count[i]-1:
            print(sosu[i])
        else:
            print(sosu[i],end=' ')

Submission status: Accepted

Solution code:
import math


def getMinprime(N):
	# 最小の素数を返す
	if n % 2 == 0:
		return 2
	nsqrt = int(math.sqrt(n))
	for i in range(2, nsqrt + 1):
		if n % i == 0:
			return i

	return N


# 入力値の取得（整数）
n = int(input())
primes = []

# 素因数分解
m = n  # 入力値の退避
while n > 1:
	minprime = getMinprime(n)
	primes.append(minprime)
	n = int(n / minprime)

# print(primes)

# 結果出力
print('{0}:'.format(m), end='')
for i in primes:
	print(' {0}'.format(i), end='')
print()

Submission status: Accepted

Solution code:
n = int(input())
n_ = n

factors = []
while n%2 == 0:
    factors.append('2')
    n //= 2

for f in range(3, int(n**0.5) + 1, 2):
    while n%f == 0:
        factors.append(str(f))
        n //= f

if n > 1:
    factors.append(str(n))

print("{}: {}".format(n_, " ".join(factors)))

Submission status: Accepted

Solution code:
from math import sqrt

n = int(input())
orig_n = n

factor = []

i = 2
while i <= sqrt(n):
    if n % i == 0:
        factor.append(i)
        n //= i
    else:
        i += 1

if n != 1:
    factor.append(n)

res = f'{orig_n}: ' + ' '.join(map(str, factor))

print(res)

Submission status: Accepted

Solution code:
n = int(input())
n1 = n
i = 2
x = []
while i*i <= n:
  while n % i == 0:
    n //= i
    x.append(str(i))
  i += 1
if n > 1:
  x.append(str(n))
print(str(n1) + ": " + " ".join(x))

Submission status: Accepted

Solution code:

def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1


n=int(input())
nn=n
# ===================================== 約数のリスト   
ir=int(n**(0.5))+1
ret=[]
for i in range(1,ir):
    if n%i == 0 and isPrime(i):
        ret.append(i)
#    if n%i == 0 and (i!= 1) & (i*i != n) and isPrime(n//i):
    if n%i == 0 and  (i*i != n) and isPrime(n//i):
            ret.append(n//i)

ret2=[]
for i in ret:
    while nn//i>0 and nn%i==0:
        ret2.append(i)
        nn=nn//i
        
print(str(n)+":",end="")
for i in ret2:
#    print(" ",i,end="")
    print("",i,end="")
print()

Submission status: Accepted

Solution code:
n = int(input())
i = 2
print(str(n)+":",end = "")

while True:
  if n%i == 0:
    n //= i
    print("",i,end = "")
    i = 2
    if n == 1:
      print("")
      break
    continue
  if i > n**0.5:
    print("",n)
    break
  i += 1

Submission status: Accepted

Solution code:
n = int(input())

print(f'{n}:', end='')
temp = n
for i in range(2, int(n**(1/2))+1):
    if temp % i == 0:
        while temp % i == 0:
            print(f' {i}', end='')
            temp //= i

if temp != 1:
    print(f' {temp}', end='')

print('')

Submission status: Accepted

Solution code:
#素因数分解して列挙する関数、約数列挙ではない！
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

N = int(input())
print('{}:'.format(N),end=' ')
print(*factorize(N))

Submission status: Accepted

Solution code:

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




a = int(input())
print(str(a)+': ',end='')
print(*prime_factor(a))

Submission status: Accepted

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

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')


def prime_factor(n):
    res = []
    dividend = n
    divisor = 2
    while divisor ** 2 <= n:
        while dividend % divisor == 0:
            dividend //= divisor
            res.append(divisor)
        divisor += 1
    if dividend != 1:
        res.append(dividend)
    return res


n = int(input())
res = prime_factor(n)
res_str = list(map(str, res))
print(f"{n}: {' '.join(res_str)}")

Submission status: Accepted

Solution code:
n = int(input())
print(str(n) + ':', end='')
while n > 1:
    for p in range(2, n+1):
        if n % p == 0:
            n //= p
            print(' ' + str(p), end='')
            break
        elif p * p > n:
            print(' ' + str(n), end='')
            n = 1
            break
print()

Submission status: Accepted

Solution code:
N = int(input())
i = 2
ans = []
n = N
while n > 1:
  if i > N**0.5:
    ans.append(str(n))
    break
  if n % i == 0:
    ans.append(str(i))
    n = n // i
  else:
    i += 1
print(str(N) + ': ' + ' '.join(ans))

Submission status: Accepted

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


n=int(input())
A=prime_factorize(n)
print("{}:".format(n),*A)

Submission status: Accepted

Solution code:
n = int(input())
x = n
divisor = []
for i in range(2,int(x**(1/2))+1):
         if n % i == 0:
                  while n % i == 0:
                           n = n // i
                           divisor.append(i)
if n != 1:
         divisor.append(n)
print(str(x)+":",*divisor)

Submission status: Accepted

Solution code:
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    n = I()

    tmp = n
    ans = []
    factor = 2
    while factor<n**0.5 and tmp>1:
        if tmp%factor == 0:
            tmp //= factor 
            ans.append(factor)
        else:
            factor += 1
    if tmp>=2:
        ans.append(tmp)
    print(str(n)+':', ' '.join([str(i) for i in ans]))

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
# import numpy as np
import math
n = int(input());
orig = n
i = 2
l = []
while i<=math.sqrt(orig):
    while n%i== 0:
        n /= i
        l.append(i)
    i += 1
if n != 1:
    l.append(int(n))
# if len(l) == 0:
#     print("{0}: {1}".format(orig, orig))
# else:
print("{}:".format(orig), *l)

Submission status: Accepted

Solution code:
N = int(input()) 
n = int(N**.5)
res = len(str(N))
arr = []
tmp = N
for i in range(2,n+1):
    if tmp % i == 0:
        while tmp % i == 0:
            arr.append(i)
            tmp = int(tmp/i)
if tmp != 1: arr.append(tmp) 
arr = [str(i) for i in arr]
print(str(N) + ": " + " ".join(arr))

Submission status: Accepted

Solution code:
n = int(input())
nn = n
N = []

print(n, ":", sep = "", end = " ") 

if n % 2 == 0 :
    while n % 2 == 0 :
        N.append(2)
        n //= 2
        
for i in range(3, int(nn ** (1 / 2)) + 1, 2) :
    while n % i == 0 :
        N.append(i)
        n //= i
        
if n != 1 :
    N.append(n)
    
if len(N) == 0 :
    print(n)
else :
    for i in range(len(N)) :
        if i == len(N) - 1 :
            print(N[i])
        else :
            print(N[i], sep = "", end = " ")

Submission status: Accepted

Solution code:
def make_prime_factors(n: int) -> list:
    """自然数nの素因数を列挙したリストを出力する
    計算量: O(sqrt(N))
    入出力例: 156 -> [2, 2, 3, 13]
    """
    prime_factors = []
    for k in range(2, int(n ** 0.5) + 1):
        while n % k == 0:
            prime_factors.append(k)
            n = n // k
    if n != 1:
        prime_factors.append(n)
    return prime_factors


n = int(input())
ans = make_prime_factors(n)
print('{}: {}'.format(n, ' '.join(map(str, ans))))

Submission status: Accepted

Solution code:
import math

n = int(input())
nc = n
ans = list()

i = 2
while(i <= math.sqrt(n)):
  if(n % i == 0):
    ans.append(str(i))
    n = n // i
  else:
    i += 1
    
if(n != 1):
  ans.append(str(n))

print(str(nc) + ': ' + ' '.join(ans))

Submission status: Accepted

Solution code:
n = int(input())
N = str(n) + ':'
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
print(N, *prime_factorize(n))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# A = list(map(int,sys.stdin.readline().split()))
# A = [sys.stdin.readline() for _ in range(N)]
# A = [list(map(int,sys.stdin.readline())) for _ in range(N)]
# A = [int(sys.stdin.readline()) for _ in range(N)]
# S = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
import sys,bisect,math
sys.setrecursionlimit(15000)

N = int(sys.stdin.readline())
ret = []
n = N
for i in range(2,math.floor(pow(N,0.5))+1):
  #print(n,i,n%i)
  while n%i==0:
    ret.append(i)
    n = n//i
if n != 1:
    ret.append(n)
print("{}: {}".format(N," ".join(map(str,ret))))
#print("{}: {}".format(N,str(ret)[1:-1]))

Submission status: Accepted

Solution code:
import sys
import math

def factorization(n):
    arr = []
    temp = n
    for i in range(2, math.ceil(math.sqrt(n))):
        if temp % i == 0:
            count = 0
            while temp % i == 0:
                count += 1
                temp //= i
            arr.append((i, count))

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

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

    return arr
        
n = int(sys.stdin.readline().strip())

factors = factorization(n)
ans = str(n) + ":"
for factor, count in factors:
    for i in range(count):
        ans += " " + str(factor)

print(ans)

Submission status: Accepted

Solution code:
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res

N = int(input())
res = prime_factorize(N)
ans = []
for v, ex in res:
    for _ in range(ex):
        ans.append(str(v))
print(str(N) + ":", " ".join(ans))

Submission status: Accepted

Solution code:

def factorize(n):
    if n < 4:
        return [n]
    res = []
    i = 2
    while i*i <= n:
        while n%i == 0:
            res.append(i)
            n //= i
        i += 1
    if n != 1:
        res.append(n)
    res.sort()
    return res

N = int(input())
f = factorize(N)
print(str(N)+": ", end="")
print(*f)

Submission status: Accepted

Solution code:
n = int(input())

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

res = prime_factorization(n)
tmp = [str(n) + ':']
res = tmp + res

print(*res)

Submission status: Accepted

Solution code:
import math

n=int(input())
end=math.sqrt(n)
q=2
print(n,":",sep="",end="")
while(True):
    if n%q==0:
        n/=q
        print(" ",q,sep="",end="")
    else:
        q+=1
    if q>end or n==1:
        break
if n>1:
    print(" ",int(n),sep="",end="")
print()

Submission status: Accepted

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

n = int(input())
ans = factorize(n)
# str_ans = str(ans)
# print(''.join(str_ans))
# print(str_ans)
# print(*ans)
print(str(n) + ': ' + ' '.join(ans))

Submission status: Accepted

Solution code:
n = int(input())

def prime_factorize(n):
    fac = []
    if n < 2: return fac
    while n%2 == 0:
        n //= 2
        fac.append(2)
    for i in range(3,int(n**0.5)+1,2):
        while n%i == 0:
            n //= i
            fac.append(i)
    if n != 1: fac.append(n)
    return fac

print("{}: {}".format(n," ".join(map(str,prime_factorize(n)))))

Submission status: Accepted

Solution code:
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A&lang=ja
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n = int(readline())
    n_ = n

    d = {}
    i = 2
    while i * i <= n:
        if n % i == 0:
            d[i] = 1
            n //= i
            while n % i == 0:
                n //= i
                d[i] += 1
        i += 1

    if n > 1:
        d[n] = 1
    
    ans = ["{}:".format(n_)]
    for k, v in d.items():
        for _ in range(v):
            ans .append(str(k))

    print(" ".join(ans))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
print('{}: '.format(n), end='')
A = []
i = 2
while n > 1:
    if n % i == 0:
        A.append(i)
        n //= i
    elif i**2 > n:
        A.append(n)
        break
    else:
        i += 1

print(*A)

Submission status: Accepted

Solution code:
def prime_factorize(N): #素因数分解
    exponent = 0
    while N%2 == 0:
        exponent += 1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i: continue
        exponent = 0
        while N%i == 0:
            exponent += 1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    return factorization

N = int(input())

f = prime_factorize(N)
ans = []
for i in range(len(f)):
    for j in range(f[i][1]):
        ans.append(f[i][0])

##print(str(N)+": "+" ".join(ans))

print(str(N) + ": ",end="")
print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
N = n
M = int(n**0.5) + 1
prime = [2]
primeflag = [False] + [False, True]*(M//2)

for i in range(3, M, 2):
    if primeflag[i] is False:
        primeflag[i] = True
        prime.append(i)
        for j in range(2*i, M, i):
            primeflag[j] = True

ans = []

for i in prime:
    while N % i == 0:
        ans.append(i)
        N //= i
else:
    if N != 1:
        ans.append(N)

print("{}:".format(n), ' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors

n = int(input())
n_ = n
div = make_divisors(n)
ans = []
for d in div[1:]:
    while n_ % d == 0 and n_ > 0:
        n_ //= d
        ans.append(d)
print("{}:".format(n), *ans)

Submission status: Accepted

Solution code:
n = int(input())

def soinsu(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 [str(_) for _ in a]
ans = str(n) + ': ' + ' '.join(soinsu(n))
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

tn = n
t = []
for i in range(2, int(n ** 0.5) + 1):
    while n % i == 0:
        n //= i
        t.append(i)

if n != 1:
    t.append(n)

print("{}: {}".format(tn, " ".join(map(str, t))))

Submission status: Accepted

Solution code:
import math

n = int(input())
x = n
print(f'{x}:', end='')
cnt = 0
for i in range(2, n+1):
    if x==1:
        break
    
    if i>math.sqrt(n) and cnt==0:
        print(f' {n}', end='')
        break
    

    while x%i==0:
        cnt += 1
        x=x//i
        print(f' {i}', end='')
        
print()

Submission status: Accepted

Solution code:
def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


if __name__ == "__main__":
    N = int(input())
    pf = prime_factorization(N)
    ans = "{}:".format(N)
    for k, v in pf:
        ans += (" {}".format(k)) * v
    print(ans)

Submission status: Accepted

Solution code:
from math import sqrt
N = int(input())
i = 2
lis = []
n = N
while True:
    if i>sqrt(n):
        if n==1:
            break
        else:
            lis.append(str(n))
            break
    if n%i==0:
        lis.append(str(i))
        n //= i
    else:
        i += 1
print('{}: '.format(N)+' '.join(lis))

Submission status: Accepted

Solution code:
def main():
    from math import sqrt
    n = int(input())
    N = n
    i = 2
    ans = []
    while i<=sqrt(n):
        if n%i==0:
            n //= i
            ans.append(str(i))
        else:
            i += 1
    if n != 1:
        ans.append(str(n))
    print(str(N)+':', ' '.join(ans))

main()

Submission status: Accepted

Solution code:
def PrimeFactorize(n):
    l = []
    for i in range(2, int(n ** 0.5) + 1):
        if i > n:
            break
        while n % i == 0:
            n //= i
            l.append(str(i))
    if n != 1:
        l.append(str(n))
    return l


n = int(input())
print(str(n) + ": " + " ".join(PrimeFactorize(n)))

Submission status: Accepted

Solution code:
n=int(input())
num=int(n**0.5)
str_n=str(n)
l=[]
for i in range(2,num+1):
    while n%i==0:
        n=n//i
        l.append(i)
if n!=1:l.append(n)
print(str_n+':',*l)

Submission status: Accepted

Solution code:
#coding utf-8
import math
import copy
n = int(input())
m = copy.copy(n)
A = []

for i in range(2,int(math.sqrt(m))+2):
    if n == 1:
        break
    if n % i == 0:
        while n % i == 0:
            A.append(str(i))
            n //= i
if n > 1:
    A.append(str(n))
print(str(m) + ': ' + ' '.join(A))

Submission status: Accepted

Solution code:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

n=int(input())
ans="{}:".format(n)
if is_prime(n)==True:
    ans+=' '
    ans+=str(n)
    print(ans)
    exit()
lis=[]
flag=True
import math
while flag:
    flag=False
    for i in range(2,n+1):
        if n%i==0:
            lis.append(i)
            n//=i
            flag=True
            break
for i in lis:
    ans+=" "
    ans+=str(i)
print(ans)

Submission status: Accepted

Solution code:
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
print(f"{n}:", " ".join(list(map(str, prime_factorize(n)))))

Submission status: Accepted

Solution code:
n = int(input())
N = n
ans = []
for i in range(2, int(n**0.5)+1):
    while n % i == 0:
        ans.append(i)
        n //= i
if n != 1: ans.append(n)
print('{}:'.format(N), *ans)

Submission status: Accepted

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

n = int(input())
ans = str(n) + ":"
for i,v in factorize(n):
    ans += (" "+str(i))*v
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    n=int(input())
    # int型mをとって、素因数をkeyに乗数をvalueに格納した辞書型pfを返す関数
    def prime_factorization(m):
        pf = {}  # keyをvalue乗

        for i in range(2, int(m ** 0.5) + 1):
            # iで割れる回数をpfに格納
            while m % i == 0:
                # get関数の第2引数はキーが存在しない場合に返すデフォルト値
                pf[i] = pf.get(i, 0) + 1
                m //= i

        # 割り切れずに残ったものは素数なのでpfにぶち込む
        if m > 1:
            pf[m] = 1

        return pf
    print('{}:'.format(n),end='')
    ans=[]
    for k, v in prime_factorization(n).items():
        for i in range(v):
            print(' {}'.format(k), end='')
    print()

resolve()

Submission status: Accepted

Solution code:
n = int(input())
_n = n

prime = []
for i in range(2, int(n**0.5)+1):
    while n%i == 0:
        prime.append(i)
        n /= i

if len(prime) == 0 or n != 1:
    prime.append(int(n))

print(str(_n) + ":", *prime)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def factorize(n):
        if n < 4:
            return [n]
        res = []
        i = 2
        while i**2 <= n:
            while n%i == 0:
                res.append(i)
                n //= i
            i += 1
        if n != 1:
            res.append(n)
        res.sort()
        return res
    n = I()
    f = factorize(n)
    print(n,end =": ")
    print(*f)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N = int(input())
A = []
def is_prime(n):
    if n<2:return False
    for i in range(2,n):
        if i*i>n:break
        if n%i==0:return False
    return True
n = N
if is_prime(n):
    A.append(n)
    n=1
for i in range(2,N):
    if n%i==0:
        while n>1:
            A.append(i)
            n//=i
            if n%i!=0:break
    if n==1:break
print(str(N)+":",*A)

Submission status: Accepted

Solution code:
from math import sqrt

n = int(input())

def prime_factors(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


factors = prime_factors(n)
print("{}:".format(n), *factors)

Submission status: Accepted

Solution code:
N = int(input())
n = N

limit = int(N ** 0.5)
A = []
for i in range(2, limit + 1):
    while n % i == 0:
        A.append(i)
        n //= i

if not n == 1:
    A.append(n)

A.sort()
print(f'{N}: {" ".join(map(str, A))}')

Submission status: Accepted

Solution code:
import math
n = int(input())

def dev(n,x):
    while n % x == 0:
        print ('',x,end='')
        n //= x
    return n

print ('{}:'.format(n),end='')
n = dev(n,2)
for x in range(3,int(math.sqrt(n))+1,2):
    if n == 1: break
    n = dev(n,x)
if n > 1:
    print ('',n)
else:
    print ('')