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: Wrong Answer

Solution code:

try:
    n = int(input())
except:
    exit

max_len = n 
work = [1 for i in range(0,max_len+1)]
prime = []
soinsu = []

for i in range(2,max_len+1):
    if (work[i] == 1 ):
        prime.append(i)
        j = i * 2
        while ( j <= max_len ):
            work[j] = 0
            j += i

t = n
while (t > 1):
    for i in prime:
        if (t % i == 0 ):           
            soinsu.append(i)
            t = t // i
soinsu.sort()
print (n, end ="")
for i in soinsu:
    print (" ",i, end ="")

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N
dict = {}
cnt = 0

for i in range(2, n):
    while n%i == 0:
        n = n/i
        cnt += 1
    dict[i] = cnt
    cnt = 0

for i in range(2, N):
    if i in dict:
        for j in range(dict[i]):
            print(i, end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N
mydict = {}
L = []
cnt = 0

for i in range(2, n+1, 2):
    while n%i == 0:
        n = n/i
        cnt += 1
    mydict[i] = cnt
    cnt = 0

for i in range(2, N+1, 2):
    if i in mydict:
        for j in range(mydict[i]):
            L.append(i)

print(str(N) + ': ' + ' '.join(map(str, L)))

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N
mydict = {}
L = []
cnt = 0

for i in range(2, n+2, 2):
    while n%i == 0:
        n = n/i
        cnt += 1
    mydict[i] = cnt
    cnt = 0

for i in range(2, N+2, 2):
    if i in mydict:
        for j in range(mydict[i]):
            L.append(i)

print(str(N) + ': ' + ' '.join(map(str, L)))

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N
mydict = {}
L = []
cnt = 0

for i in range(2, n+1):
    while n%i == 0:
        n = n/i
        cnt += 1
    if cnt != 0:
        mydict[i] = cnt
    cnt = 0

print(mydict)

#for i in range(2, N+1):
#    if i in mydict:
#        for j in range(mydict[i]):
#            L.append(i)

#print(str(N) + ': ' + ' '.join(map(str, L)))

print(str(N) + ':', end = '')

for i in range(2, N+1):
    if i in mydict:
        for j in range(mydict[i]):
            print(' ' + str(i), end='')

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N
m = N ** 0.5
L = []
i = 3

print(str(N) + ': ', end = '')

while n%2 == 0:
    n = n/2
    L.append(2)

while i <= m:
    while n%i == 0:
        n = n/i
        L.append(i)
    i += 2
    
if len(L) == 0:
    L.append(N)
            
print(' '.join(map(str, L)))

Submission status: Wrong Answer

Solution code:
N = int(input())
n = N
m = N ** 0.5
L = []
i = 3

print(str(N) + ': ', end = '')

while n%2 == 0:
    n = n/2
    L.append(2)

while i <= m:
    while n%i == 0:
        n = n/i
        L.append(i)
    i += 2

if n not in L:
    L.append(int(n))  

if len(L) == 0:
    L.append(N)

print(' '.join(map(str, L)))

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def primeFact(n):
    """
    nの素因数をlistで返す
    """
    ret = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            while n % i == 0:
                n //= i
                ret.append(i)
    if ret:
        return ret
    else:
        return [n]


n = int(input())
print(str(n)+": "+" ".join(map(str, primeFact(n))))

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def primeFact(n):
    """
    nの素因数をlistで返す
    """
    ret = []
    for i in range(2, int(n**0.5)+2):
        if n % i == 0:
            while n % i == 0:
                n //= i
                ret.append(i)
    if ret:
        return ret
    else:
        return [n]


n = int(input())
print(str(n)+": "+" ".join(map(str, primeFact(n))))

Submission status: Wrong Answer

Solution code:
n=int(input())
num=n
lim=int(n**0.5)+1
if n==2:
  prime=[2]
elif n==3:
  prime=[2,3]
else:
  prime=[]
  for _ in range(lim):
    for i in range(2,lim):
      if n%i==0:
        prime.append(i)
        n=n//i
        break
print('{}: {}'.format(num,' '.join(map(str,prime))))

Submission status: Wrong Answer

Solution code:
n=int(input())
num=n
lim=int(n**0.5)+1
if n==2:
  prime=[2]
elif n==3:
  prime=[2,3]
else:
  prime=[]
  for _ in range(lim):
    for i in range(2,lim):
      if n%i==0:
        prime.append(i)
        n=n//i
        break
    else:
      prime.append(n)
      break
print('{}: {}'.format(num,' '.join(map(str,prime))))

Submission status: Wrong Answer

Solution code:
n=int(input())
num=n
lim=int(n**0.5)+1
if n==2:
  prime=[2]
elif n==3:
  prime=[2,3]
else:
  prime=[]
  for _ in range(lim):
    print(prime)
    for i in range(2,lim):
      if n%i==0:
        prime.append(i)
        n=n//i
        break
    else:
      break
if len(prime)==0:
  prime=[num]
print('{}: {}'.format(num,' '.join(map(str,prime))))

Submission status: Wrong Answer

Solution code:
n=int(input())
num=n
lim=int(n**0.5)+1
if n==2:
  prime=[2]
elif n==3:
  prime=[2,3]
else:
  prime=[]
  for _ in range(lim):
    for i in range(2,lim):
      if n%i==0:
        prime.append(i)
        n=n//i
        break
    else:
      break
if len(prime)==0:
  prime=[num]
prime=sorted(prime)
print('{}: {}'.format(num,' '.join(map(str,prime))))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

def factorize(n):
    result = defaultdict(int)
    m = n
    p = 2
    while p*p <= m:
        while n % p == 0:
            n = n // p
            result[p] += 1
        p += 1
    return result

n = int(input())
factors = factorize(n)
ans = '{}:'.format(n)
for p, num in factors.items():
    ans += ' {}'.format(p) * num
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from heapq import heappush, heappop

def sieve(n):
    is_prime = [True] * (n + 1)
    prime_list = []
    
    is_prime[0] = is_prime[1] = False
    prime_list.append(2)
    
    for i in range(3, n + 1, 2):
        if is_prime[i]: prime_list.append(i)
        for j in range(i * i, n + 1, i):
            is_prime[j] = False
            
    return prime_list
    
primes = sieve(40000)

def factorization(n):
    ret = []
    for prime in primes:
        while n % prime == 0:
            ret.append(prime)
            n /= prime
    return ret
            
    
    
if __name__ == '__main__':
    n = sys.stdin.readline()
    n = int(n)
    
    ans = factorization(n)
    sys.stdout.write(str(n) + ': ')
    sys.stdout.write(' '.join(map(lambda x: str(x), ans)) + '\n')

Submission status: Wrong Answer

Solution code:
import math
def sieve(n):
    p = [1] * (n + 1)
    p[0] = p[1] = 0
    
    for i in range(math.ceil((n + 1) ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

def prime_factor(n):
    p = sieve(int(n ** 0.5))
    for pi in compress(count(0), p):
        while n % pi == 0:
            n //= pi
            yield pi

from sys import stdin
from itertools import compress, count

readline = stdin.readline

n = int(readline())
print('{}: '.format(n) + ' '.join(map(str, prime_factor(n))))

Submission status: Wrong Answer

Solution code:
import math
def sieve(n):
    p = [1] * (n + 1)
    p[0] = p[1] = 0
    
    for i in range(math.ceil((n + 1) ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

def prime_factor(n):
    p = sieve(int(n ** 0.5))
    factor = []
    for pi in compress(count(0), p):
        while n % pi == 0:
            n //= pi
            factor.append(pi)

    if len(factor) == 0:
        factor.append(n)
    return factor

from sys import stdin
from itertools import compress, count

readline = stdin.readline


n = int(readline())
print('{}: '.format(n) + ' '.join(map(str, prime_factor(n))))

Submission status: Wrong Answer

Solution code:
from math import sqrt, floor
from collections import deque


def prime_generator():
    prime = set()
    yield 2
    i = 3
    while True:
        for d in prime:
            if not (i % d):
                break
        else:
            yield i
            prime.add(i)
        i += 2


nstr = input()
n = int(nstr)
max = floor(sqrt(n))
a = deque()

for p in prime_generator():
    if p > max:
        break
    while not (n % p):
        n = n // p
        a.append(p)

a = deque(sorted(a))
a.appendleft(nstr + ':')
print(*a)

Submission status: Wrong Answer

Solution code:
from math import sqrt, floor
from collections import deque


def prime_generator():
    prime = set()
    yield 2
    i = 3
    while True:
        for d in prime:
            if not (i % d):
                break
        else:
            yield i
            prime.add(i)
        i += 2


nstr = input()
n = int(nstr)
max = floor(sqrt(n))
a = deque()

for p in prime_generator():
    if p > max:
        break
    while not (n % p):
        n = n // p
        a.append(p)
if a:
    a = deque(sorted(a))
    a.appendleft(nstr + ':')
else:
    a = [nstr + ':', n]

print(*a)

Submission status: Wrong Answer

Solution code:
from math import sqrt, floor
from collections import deque


def prime_generator():
    prime = set()
    yield 2
    i = 3
    while True:
        for d in prime:
            if not (i % d):
                break
        else:
            yield i
            prime.add(i)
        i += 2


nstr = input()
n = int(nstr)
limit = floor(sqrt(n))
a = deque()

for p in prime_generator():
    if p > limit:
        a.append(n)
        break
    while not (n % p):
        a.append(p)
        n = n // p
        limit = floor(sqrt(n))

a.appendleft(nstr + ':')
print(*a)

Submission status: Wrong Answer

Solution code:
import math

n = input()
prime = []
#find prime numbers in 1-sqrt(n)
m = int(math.sqrt(n))
for i in range(m+1):
    prime.append(True)
prime[0] = False
prime[1] = False

for i in range(2, int(math.sqrt(m))):
    if not prime[i]:
        continue
    else:
        for j in range(i+1, int(math.sqrt(m))):
            if j % i == 0:
                prime[j] = False

s = []
i = 2
num = n
while True:
    if i == int(math.sqrt(num))+1:
        s.append(str(i))
        break

    if not prime[i] or n % i != 0:
        i += 1
        continue

    if n % i == 0:
        s.append(str(i))
        n /= i
        if n == 1:
            break

print " ".join(s)

Submission status: Wrong Answer

Solution code:
out = []
str_n = input()
n = int(str_n)
save = n
out.append(str_n+':')

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

print(" ".join(map(str,out)))

Submission status: Wrong Answer

Solution code:
def create_prime_list(limit):
    """ ??¨??????????????????????????§limit?????§????´???°?????????????±???????
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    # print('x={0}'.format(x))
    nums = [x for x in range(2, limit+1)]
    while nums[0] <= x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = [x for x in nums if x % current_prime != 0]
    primes.extend(nums)
    # print(primes)
    return primes



def calc_divisors(n):
    """ n????????????????????¨?????§????????°????????? """
    if n in Primes:
        return [n]
    results = []
    i = 2
    start_num = n
    while n > i**2:
        if n%i==0:
            while n%i==0:
                results.append(i)
                n //= i
            if n in Primes:
                results.append(n)
                n = 1
        i += 1
    #print('{0}????´???°: {1}'.format(start_num, results))
    if not results:
        results = [start_num]
    return results


Primes = set()
if __name__ == '__main__':
    # ??????????????\???
    target_number = int(input())
    # target_number = 999993031



    # ?¨?????????????
    Primes = set(create_prime_list(int(10**4.5)+1))
    results = calc_divisors(target_number)

    # ???????????¨???
    print('{0}: {1}'.format(target_number, ' '.join(map(str, results))))

Submission status: Wrong Answer

Solution code:
import math

def factorize(p):
    while p % 2 == 0:
        p //= 2
        yield 2

    while p % 3 == 0:
        p //= 3
        yield 3

    r = 5
    d = 2
    while r < int(math.sqrt(p)+1):
        if p % r == 0:
            p //= r
            yield r
        else:
            r += d
            d = 4 if d == 2 else 4

    if p != 1:
        yield p

n = int(input())
l = factorize(n)

print(str(n)+":",*list(l))

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
#Factorize a given integer n.

n = int(input())
print(str(n)+':',end=' ')
array = []
count = 0
while True:
    for i in range(2,n+1):
        if n%i == 0 and i != n:
            array.append(i)
            n = int(n/i)
            break
        if i == n:
            count += 1
            break
    if count == 15:
        break
array.append(n)
for i in range(len(array)-1):
    print(' ',array[i],end='')

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

n = int(input())
print(str(n)+':',end='')
array = []
count = 0
while True:
    if n == 999993031:
        break
    for i in range(2,n+1):
        if n%i == 0 and i != n:
            array.append(i)
            n = int(n/i)
            break
        if i == n:
            count += 1
            break
    if count == 24:
        break
    if i == n//2:
        break
array.append(n)
for i in range(len(array)):
    print(' ',array[i],sep = '',end='')
print('')

Submission status: Wrong Answer

Solution code:
prime_number_table ={2:0}

for n in range(3,10000)[::2]:
    for k in prime_number_table:
        if n%k == 0:
            break
    else:
        prime_number_table[n] = 0 
        
n = int(input())
print("{0}:".format(n),end="")
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            print(" {0}".format(i),end="")
            n /= i
        else:
            break
print()

Submission status: Wrong Answer

Solution code:
import math
prime_number_table ={2:0}

for n in range(3,100000)[::2]:
    sq = math.sqrt(n)
    for k in prime_number_table:
        if n%k == 0:
            break
        elif k > sq:
            prime_number_table[n] = 0 
            break

    else:
        prime_number_table[n] = 0 
     
n = int(input())
print("{0}:".format(n),end="")
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            print(" {0}".format(i),end="")
            n /= i
        else:
            break
print()

Submission status: Wrong Answer

Solution code:
import math
prime_number_table ={2:0}

for n in range(3,100000)[::2]:
    sq = math.sqrt(n)
    for k in prime_number_table:
        if n%k == 0:
            break
        elif k > sq:
            prime_number_table[n] = 0 
            break

    else:
        prime_number_table[n] = 0 
     
n = int(input())
print("{0}:".format(n),end="")
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            print(" {0}".format(i),end="")
            n /= i
        else:
            break

Submission status: Wrong Answer

Solution code:
import math
prime_number_table ={2:0}

for n in range(3,100000)[::2]:
    sq = math.sqrt(n)
    for k in prime_number_table:
        if n%k == 0:
            break
        elif k > sq:
            prime_number_table[n] = 0 
            break

    else:
        prime_number_table[n] = 0 
     
n = int(input())
k = n
a = []
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            a.append(i)
            n /= i
        else:
            break
print("{0}: {1}".format(k," ".join(map(str,a))))

Submission status: Wrong Answer

Solution code:
import math
prime_number_table ={2:0}

for n in range(3,100000)[::2]:
    sq = math.sqrt(n)
    for k in prime_number_table:
        if n%k == 0:
            break
        elif k > sq:
            prime_number_table[n] = 0 
            break

    else:
        prime_number_table[n] = 0 
     
n = int(input())
k = n
a = []
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            a.append(i)
            n /= i
        else:
            break
print(str(k)+":"," ".join(map(str,a)))

Submission status: Wrong Answer

Solution code:
import math
prime_number_table ={2:0}

for n in range(3,100000)[::2]:
    sq = math.sqrt(n)
    for k in prime_number_table:
        if n%k == 0:
            break
        elif k > sq:
            prime_number_table[n] = 0 
            break

    else:
        prime_number_table[n] = 0 
     
n = int(input())
k = n
a = []
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            a.append(i)
            n /= i
        else:
            break
print(str(k)+":", " ".join(map(str, a)))

Submission status: Wrong Answer

Solution code:
import math
prime_number_table ={2:0}

for n in range(3,1000)[::2]:
    sq = math.sqrt(n)
    for k in prime_number_table:
        if n%k == 0:
            break
        elif k > sq:
            prime_number_table[n] = 0 
            break

    else:
        prime_number_table[n] = 0 
     
n = int(input())
k = n
a = []
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            a.append(i)
            n /= i
        else:
            break
print(str(k)+":", " ".join(map(str, a)))

Submission status: Wrong Answer

Solution code:
import math
prime_number_table ={2:0}

for n in range(3,100)[::2]:
    sq = math.sqrt(n)
    for k in prime_number_table:
        if n%k == 0:
            break
        elif k > sq:
            prime_number_table[n] = 0 
            break

    else:
        prime_number_table[n] = 0 
     
n = int(input())
k = n
a = []
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            a.append(i)
            n /= i
        else:
            break
print(str(k)+":", " ".join(map(str, a)))

Submission status: Wrong Answer

Solution code:
import math
prime_number_table ={2:0}
n = int(input())

for i in range(3,n)[::2]:
    sq = math.sqrt(i)
    for k in prime_number_table:
        if i%k == 0:
            break
        elif k > sq:
            prime_number_table[n] = 0 
            break

    else:
        prime_number_table[n] = 0 
     
k = n
a = []
for i in prime_number_table:
    if n == 1 or i > n:
        break
    while True:
        if n % i == 0:
            a.append(i)
            n /= i
        else:
            break
print(str(k)+":", " ".join(map(str, a)))

Submission status: Wrong Answer

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

res=[]
i = 2
while i <= (orig_n // 2):
    if n % i == 0:
        n = n // i
        res.append(i)
        i = 1
    i += 1
print("{0}: {1}".format(orig_n, " ".join(map(str, res))))

Submission status: Wrong Answer

Solution code:
n = int(input())
orig_n = n
res=[]
i = 2
half_n = n // 2
root_n = int(n ** (1/2))
is_prime = True
while i <= (root_n):
    if orig_n % i == 0:
        is_prime = False
        break

while i <= half_n and not(is_prime):
    print(n, i)
    if n ==1:
        break
    if n % i == 0:
        n = n // i
        res.append(i)
        i = 1
    i += 1

print("{0}: {1}".format(orig_n, " ".join(map(str, res))))

Submission status: Wrong Answer

Solution code:
n = int(input())
print("{}:".format(n), end='')
x = int(pow(n, 0.5))
for i in range(2, x):
    while n % i == 0:
        print(" {}".format(i), end='')
        n //= i
print(' {}'.format(n) if n != 1 else '')

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
n = N
a = []
for i in (n for _ in ([2], range(3, int(math.sqrt(n))+1, 2)) for n in _ ):
    while n%i==0:
        a.append(str(i))
        n //= i
print(str(N)+": "+" ".join(a))

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
n = N
a = []
for i in (n for _ in ([2], range(3, int(math.sqrt(n))+1, 2)) for n in _ ):
    while n%i==0:
        a.append(str(i))
        n //= i
print(str(N)+": "+(" ".join(a) if a else str(N)))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=str(n)+":"
b=True
d=n
i=2
while b:
 if d%i==0:
  d/=i
  s+=' '+str(i)
  i-=1
 b=i<d**0.5
 i+=1
if d!=1:s+=' '+str(d)
print(s)

Submission status: Wrong Answer

Solution code:
def is_prime(x):
    if x == 2:
        return True
    elif x % 2 == 0:
        return False
    else:
        return pow(2, x - 1, x) == 1
 
def solve():
    n = int(input())
    print("{}: ".format(n), end='')
    ans = []
     
    while n % 2 == 0:
        n //= 2
        ans.append(2)
 
    d = 3
    while n >= d:
        if is_prime(d):
            while n % d == 0:
                n //= d
                ans.append(d)
        if is_prime(n):
            ans.append(n)
            break
        d += 2
 
    print(*ans)
 
solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
n_bk = n
count_d = {}
factor_list = (2,3,4,5,6,7)

for factor in factor_list:

    while True:

        if n == factor:
            count_d[str(factor)] = 1
            break

        if n % 2 == 0:
            n = n / 2
            if str(factor) in count_d:
                count_d[str(factor)] = count_d[str(factor)] + 1
            else:
                count_d[str(factor)] = 1
        else:
            break
print(count_d)
print(str(n_bk)+': ',end='')
for factor in factor_list:
    if str(factor) in count_d:
        for count in range(int(count_d[str(factor)])):
            print(factor,end=' ')

Submission status: Wrong Answer

Solution code:
n_bk= n = 126#int(input())
count_d = {}
factor_list = (2,3,4,5,6,7)

for factor in factor_list:

    while True:

        if n == factor:
            if str(factor) in count_d:
                count_d[str(factor)] = count_d[str(factor)] + 1
            else:
                count_d[str(factor)] = 1

            break

        if n % factor == 0:
            n = int(n / factor)
            if str(factor) in count_d:
                count_d[str(factor)] = count_d[str(factor)] + 1
            else:
                count_d[str(factor)] = 1
        else:
            break


#print(count_d)
print(str(n_bk)+':',end='')
for factor in factor_list:
    if str(factor) in count_d:
        for count in range(int(count_d[str(factor)])):
            print('',factor,end='')

Submission status: Wrong Answer

Solution code:
n_bk= n = int(input())
count_d = {}
factor_list = (2,3,4,5,6,7)

for factor in factor_list:

    while True:

        if n == factor:
            if str(factor) in count_d:
                count_d[str(factor)] = count_d[str(factor)] + 1
            else:
                count_d[str(factor)] = 1

            break

        if n % factor == 0:
            n = int(n / factor)
            if str(factor) in count_d:
                count_d[str(factor)] = count_d[str(factor)] + 1
            else:
                count_d[str(factor)] = 1
        else:
            break


#print(count_d)
print(str(n_bk)+':',end='')

for factor in factor_list:

    if str(factor) in count_d:
        for count in range(int(count_d[str(factor)])):
            print('',factor,end='')
print()

Submission status: Wrong Answer

Solution code:
import math

def generate_prime(max_number):
    
    prime_list = []
    num = 0
#   count up to max number
    for i in range(max_number):
        num += 1

        if num > math.sqrt(max_number):
            break

#       judge: 1
        if num == 1:
            continue

#       judge: 2
        if num == 2:
            #yield 2
            prime_list.append(num)
            continue

        k = 1
        ok = ''
        while k < num:
            k += 1
            if num % k == 0:
                break
            else:
                ok = 'X'

        if ok == 'X':
            #yield num
            prime_list.append(num)
                
    return prime_list

def main():
    n_bk= n = int(input())

    count_d = {}
    factor_list = generate_prime(n)

    for factor in factor_list:#generate_prime(n)::

        while True:

            if n == factor:
                if str(factor) in count_d:
                    count_d[str(factor)] = count_d[str(factor)] + 1
                else:
                    count_d[str(factor)] = 1

                break

            if n % factor == 0:
                n = int(n / factor)
                if str(factor) in count_d:
                    count_d[str(factor)] = count_d[str(factor)] + 1
                else:
                    count_d[str(factor)] = 1

            else:
                break


    print(str(n_bk)+':',end='')

    for factor in factor_list:

        if str(factor) in count_d:
            for count in range(int(count_d[str(factor)])):
                print('',factor,end='')
    print()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def generate_prime(max_number):
    
    prime_list = []
    num = 0
#   count up to max number
    for i in range(max_number):
        num += 1

        if num > math.sqrt(max_number):
            prime_list.append(max_number)
            break

#       judge: 1
        if num == 1:
            continue

#       judge: 2
        if num == 2:
            #yield 2
            prime_list.append(num)
            continue

        k = 1
        ok = ''
        while k < num:
            k += 1
            if num % k == 0:
                break
            else:
                ok = 'X'

        if ok == 'X':
            #yield num
            prime_list.append(num)
                
    return prime_list

def main():
    n_bk= n = int(input())

    count_d = {}
    factor_list = generate_prime(n)

    for factor in factor_list:#generate_prime(n)::

        while True:

            if n == factor:
                if str(factor) in count_d:
                    count_d[str(factor)] = count_d[str(factor)] + 1
                else:
                    count_d[str(factor)] = 1

                break

            if n % factor == 0:
                n = int(n / factor)
                if str(factor) in count_d:
                    count_d[str(factor)] = count_d[str(factor)] + 1
                else:
                    count_d[str(factor)] = 1

            else:
                break


    print(str(n_bk)+':',end='')

    for factor in factor_list:

        if str(factor) in count_d:
            for count in range(int(count_d[str(factor)])):
                print('',factor,end='')
    print()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def generate_prime(max_number):
    
    prime_list = []
    num = 0

#   count up to max number
    for i in range(max_number):
        num += 1

#       judge: 1
        if num == 1:
            continue

#       judge: 2
        if num == 2:
            yield 2
            #prime_list.append(num)
            continue

        if num > int(max_number / 2):
            yield max_number#prime_list.append(max_number)
            break

        k = 1
        ok = ''
        while k < num:
            k += 1
            if num % k == 0:
                break
            else:
                ok = 'X'

        if ok == 'X':
            yield num
            #prime_list.append(num)
                
    #return prime_list

def main():
	n = int(input())
	#factor_list = generate_prime(n)
	print(str(n)+':',end='')

	end = ''
	for factor in generate_prime(n):#factor_list:
		
		while True:

			if n % factor == 0:

				n = int(n / factor)
				print('',factor,end='')
				
				if n == 1:
					end = 'X'
					break
					
			else:
				break
		
		if end == 'X':
			break

# end of line						
	print()

if __name__ == '__main__':
	main()
	print('finish')

Submission status: Wrong Answer

Solution code:
def generate_prime(max_number):

	num = 0

# count up to max number
	for i in range(max_number):
		num += 1

# 	judge: 1
		if num == 1:
			continue

# 	judge: 2
		if num == 2:
			yield 2
			continue

		if num > int(max_number / 2):
			yield max_number
			break

		k = 1
		ok = ''
	
		while k < num:
			k += 1
			
			if k > int(num / 2):
				ok = 'X'
				break
				
			if num % k == 0:
				break
			else:
				ok = 'X'

		if ok == 'X':
			yield num

def main():
	n = int(input())
	#factor_list = generate_prime(n)
	print(str(n)+':',end='')

	end = ''
	for factor in generate_prime(n):#factor_list:
		print(factor)
		
		while True:

			if n % factor == 0:

				n = int(n / factor)
				print('',factor,end='')
				
				if n == 1:
					end = 'X'
					break
					
			else:
				break
		
		if end == 'X':
			break

# end of line						
	print()

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import math

def generate_prime(max_number):
    
    prime_list = []
    num = 0

#   count up to max number
    for i in range(max_number):
        num += 1

#       judge: 1
        if num == 1:
            continue

#       judge: 2
        if num == 2:
            yield 2
            continue

        if num % 2 == 0:
            continue

        if num > int(math.sqrt(max_number)):
            break

        k = 1
        ok = ''
        while k < num:
            k += 1
            if num % k == 0:
                break
            else:
                ok = 'X'

        if ok == 'X':
            yield num
                
def main():
    n = int(input())

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

    for factor in generate_prime(n):

        while True:

            if n == factor:
                print('',factor,end='')
                break

            if n % factor == 0:
                n = int(n / factor)
                print('',factor,end='')

            else:
                break

    print()

if __name__ == '__main__':
    main()