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:
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)):
            yield 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()

Submission status: Wrong Answer

Solution code:
import math

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

    if max_number == 1:
        return 0
    elif max_number >= 2:
        yield 2

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

#       judge: 1
        if num == 1:
            continue

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

        if num % 2 == 0:
            continue

        if num > int(max_number / 2):
            yield 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())

    if n >= 2:
        print(str(n)+':',end='')

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

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

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

            else:
                break
        if end == 'X':
            break

    print()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

    if max_number == 1:
        return 0
    elif max_number >= 2:
        yield 2

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

#       judge: 1
        if num == 1:
            continue

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

        if num % 2 == 0:
            continue

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

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

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

    if n >= 2:
        print(str(n)+':',end='')

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

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

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

            else:
                break
        if end == 'X':
            break

    print()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

    if max_number == 1:
        return 0
    elif max_number >= 2:
        yield 2

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

#       judge: 1
        if num == 1:
            continue

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

        if num % 2 == 0:
            continue

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

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

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

    if n >= 2:
        print(str(n)+':',end='')

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

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

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

            else:
                break
        if end == 'X':
            break

    print()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def primejudge(n):
    if n<2:
        return False
    i=2
    while i<=math.sqrt(n):
        if n%i==0:
            return False
        i+=1
    return True

n=int(input())
i=2
print(str(n)+':',end=' ')

while i<n:
    while primejudge(i)==False:
        i+=1
    while n%i==0:
        print(i,end=' ')
        n=n/i
    i+=1
print('\b')

Submission status: Wrong Answer

Solution code:
import math

def primejudge(n):
    if n<2:
        return False
    i=2
    while i<=math.sqrt(n):
        if n%i==0:
            return False
        i+=1
    return True

n=int(input())
i=2
print(str(n)+':',end=' ')

while i<n:
    while primejudge(i)==False:
        i+=1
    while n%i==0:
        print(i,end=' ')
        n=n/i
    i+=1
print('\b',end='')

Submission status: Wrong Answer

Solution code:
n = int(input())
m = n
ary = []
for i in range(2,n):
    while True:
        if n % i == 0:
            ary.append(i)
            n /= i
        else:
            break
    if n == 1:
        break
    
print("m:",end="")
for i in range(len(ary)):
    print(" {}".format(ary[i]),end="")

Submission status: Wrong Answer

Solution code:
n = int(input())
m = n
ary = []
for i in range(2,n):
    while True:
        if n % i == 0:
            ary.append(i)
            n /= i
        else:
            break
    if n == 1:
        break
    
print("m:",end="")
for i in range(len(ary)):
    print(" {}".format(ary[i]),end="")
print()

Submission status: Wrong Answer

Solution code:
n = int(input())
m = n
ary = []
for i in range(2,n):
    while True:
        if n % i == 0:
            ary.append(i)
            n /= i
        else:
            break
    if n == 1:
        break
    
print("{}:".format(m),end="")
for i in range(len(ary)):
    print(" {}".format(ary[i]),end="")
print()

Submission status: Wrong Answer

Solution code:
# coding=utf-8
import array
import math


def sieve_of_eratosthenes(end):
    """
    :type end: int
    :rtype: array.array
    """
    # noinspection PyUnusedLocal
    is_prime = array.array('B', (True for i in range(end+1)))
    is_prime[0] = False
    is_prime[1] = False

    primes = array.array("L")
    for i in range(2, end+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i * 2, end+1, i):
                is_prime[j] = False
    return primes


if __name__ == '__main__':
    N = int(input())
    n = N
    upper_n = int(math.sqrt(n)) + 1
    print(upper_n)
    prime_list = sieve_of_eratosthenes(upper_n)
    print(prime_list)
    elementary_number_list = array.array("L")
    counter = 0

    while counter < len(prime_list):
        if n % prime_list[counter] == 0:
            elementary_number_list.append(prime_list[counter])
            n //= prime_list[counter]
        else:
            counter += 1

    print("{0}: {1}".format(N, ' '.join(map(str, elementary_number_list))))

Submission status: Wrong Answer

Solution code:
# coding=utf-8
import array
import math


def sieve_of_eratosthenes(end):
    """
    :type end: int
    :rtype: array.array
    """
    # noinspection PyUnusedLocal
    is_prime = array.array('B', (True for i in range(end+1)))
    is_prime[0] = False
    is_prime[1] = False

    primes = array.array("L")
    for i in range(2, end+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i * 2, end+1, i):
                is_prime[j] = False
    return primes


if __name__ == '__main__':
    N = int(input())
    n = N
    upper_n = int(math.sqrt(n)) + 1
    prime_list = sieve_of_eratosthenes(upper_n)
    elementary_number_list = array.array("L")
    counter = 0

    while counter < len(prime_list):
        if n % prime_list[counter] == 0:
            elementary_number_list.append(prime_list[counter])
            n //= prime_list[counter]
        else:
            counter += 1

    print("{0}: {1}".format(N, ' '.join(map(str, elementary_number_list))))

Submission status: Wrong Answer

Solution code:
# coding=utf-8
import array
import math


def sieve_of_eratosthenes(end):
    """
    :type end: int
    :rtype: array.array
    """
    # noinspection PyUnusedLocal
    is_prime = array.array('B', (True for i in range(end+1)))
    is_prime[0] = False
    is_prime[1] = False

    primes = array.array("L")
    for i in range(2, end+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i * 2, end+1, i):
                is_prime[j] = False
    return primes


if __name__ == '__main__':
    N = int(input())
    n = N
    upper_n = int(math.sqrt(n)) + 1
    prime_list = sieve_of_eratosthenes(upper_n)
    elementary_number_list = array.array("L")
    counter = 0

    while counter < len(prime_list):
        if n % prime_list[counter] == 0:
            elementary_number_list.append(prime_list[counter])
            n //= prime_list[counter]
        else:
            counter += 1

    if not elementary_number_list:
        elementary_number_list.append(N)

    print("{0}: {1}".format(N, ' '.join(map(str, elementary_number_list))))

Submission status: Wrong Answer

Solution code:
m=input();n=int(m);k=int(n**.5);a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i < k:
 if n%(i-1)==0:a+=[i-1];n//=i-1
 elif n%(i+1)==0:a+=[i+1];n//=i+1
 else:i+=6
print(m+':',*a)

Submission status: Wrong Answer

Solution code:
m=input();n=int(m);a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i<n**.5:
 if n%(i-1)==0:a+=[i-1];n//=i-1
 elif n%(i+1)==0:a+=[i+1];n//=i+1
 else:i+=6
print(m+':',[*a,n][i==n])

Submission status: Wrong Answer

Solution code:
m=input();n=int(m);a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i<n**.5:
 if n%(i-1)==0:a+=[i-1];n//=i-1
 elif n%(i+1)==0:a+=[i+1];n//=i+1
 else:i+=6
if i>1:a+=[n]
print(m+':',*a)

Submission status: Wrong Answer

Solution code:
m=input();n=int(m);a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i<n**.5:
 if n%(i-1)==0:a+=[i-1];n//=i-1
 elif n%(i+1)==0:a+=[i+1];n//=i+1
 else:i+=6
if n>1:a+=[m]
print(m+':',*a)

Submission status: Wrong Answer

Solution code:
m=input();n=int(m);s=n**.5;a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i<s:
 if n%(i-1)==0:a+=[i-1];n//=i-1
 elif n%(i+1)==0:a+=[i+1];n//=i+1
 else:i+=6
if n==m:a+=[m]
print(m+':',*a)

Submission status: Wrong Answer

Solution code:
m=input();n=int(m);s=n**.5;a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i<s:
 if n%(i-1)==0:a+=[i-1];n//=i-1
 elif n%(i+1)==0:a+=[i+1];n//=i+1
 else:i+=6
if n==int(m):a+=[m]
print(m+':',*a)

Submission status: Wrong Answer

Solution code:
N = int(input())
M = N
result = []
i = 2
while i * i <= N:
    while N % i == 0:
        N /= i
        result.append(i)
    i += 1
if N > 1:
    result.append(N)
print(str(M) + ": " + " ".join(map(str, result)))

Submission status: Wrong Answer

Solution code:
def soinnsubunkai(n) :
	a = 2
	soinsuu = []
	while n <= a :
		while n % a == 0:
			n /= a
			soinsuu.appwnd(x)
		a += 1
	if n  > 1:
		rable.append(n)
	return table

Submission status: Wrong Answer

Solution code:
n=int(input())
p=n
x=[]
for i in range(2,p):
    if n%i==0:
        n=n/i
        x.append(i)
print(p,':',x)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=n
x=[]
i=2
while n!=1:
    if n%i==0:
        n=n/i
        x.append(i)
    else:
        i+=1
print(p,':',x)

Submission status: Wrong Answer

Solution code:
n=input()
N=n
a=[]

while n>2:
	for i in range(2,N):
		if n%i==0:
			n=n/i
			a.append(str(i))
			break

print str(N)+": "+" ".join(a)

Submission status: Wrong Answer

Solution code:
import math
n=input()
N=n
a=[]

x=2
while x*x<=N:
	while n%x==0:
		a.append(str(x))
		n=n/x
	if n==1: break
	x+=1
else:
	a.append(str(x))


print str(N)+": "+" ".join(a)

Submission status: Wrong Answer

Solution code:
import math

def simple_prime_factrize(x):
    pfs = []
    for y in range(2, math.ceil(math.sqrt(x))):
        if x == 1: break
        while True:
            if x%y == 0:
                pfs.append(y)
                x = x/y
            else:
                break
    return pfs

n = int(input())
print(str(n) + ': ' + ' '.join([str(x) for x in simple_prime_factrize(n)]))

Submission status: Wrong Answer

Solution code:
import math

def simple_prime_factrize(x):
    pfs = []
    for y in range(2, math.ceil(math.sqrt(x))):
        if x == 1: break
        while True:
            if x%y == 0:
                pfs.append(y)
                x = x/y
            else:
                break
    if len(pfs) == 0:
        pfs.append(x)
    return pfs

n = int(input())
print(str(n) + ': ' + ' '.join([str(x) for x in simple_prime_factrize(n)]))

Submission status: Wrong Answer

Solution code:
import math

def simple_prime_factrize(x):
    pfs = []
    for y in range(2, math.ceil(math.sqrt(x))):
        if x == 1: break
        while True:
            if x%y == 0:
                pfs.append(y)
                x = x/y
            else:
                break
    if len(pfs) == 0:
        pfs.append(x)
    return pfs
    
n = int(input())
print(str(n) + ': ' + ' '.join([str(x) for x in simple_prime_factrize(n)]))

Submission status: Wrong Answer

Solution code:
import math

def simple_prime_factrize(x):
    pfs = []
    s = math.sqrt(x)
    for y in range(2, math.floor(s)):
        if x == 1: break
        while True:
            if x%y == 0:
                pfs.append(y)
                x = x/y
            else:
                break
    if len(pfs) == 0:
        pfs.append(x)
    elif x > s:
        pfs.append(int(x))
    return pfs
    
n = int(input())
print(str(n) + ': ' + ' '.join([str(x) for x in simple_prime_factrize(n)]))

Submission status: Wrong Answer

Solution code:
import math

s = "{0}:"
s2 = " {0}"
def prime_factorize(n):
	m = math.sqrt(n)+1
	i = 2
	prime = []
	while n != 1 and i < m:
		if n % i == 0:
			prime.append(i)
			n //= i
		else:
			i += 1
	return prime
n = int(input())
lst = prime_factorize(n)
print(s.format(n),end="")
for i in range(len(lst)):
	print(s2.format(lst[i]),end="")
print()

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
_N = N

ans = ''

def prime(m):
    p = [1]*m
    p[0] = 0
    sqrt = int(math.sqrt(m))
    for i in range(2,sqrt+1):
        for j in range(2,int(m/i)+1):
            p[i*j-1] = 0
    return([i+1 for i in range(m) if p[i] == 1 ])

for i in prime(N):
    while(N%i == 0):
        ans = ans + ' ' + str(i)
        N = N/i

print(str(_N)+';'+ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

print('{}:'.format(n)),
for i in range(2, n):
	while n%i==0:
		print(' {}'.format(i)),
		n=n/i

Submission status: Wrong Answer

Solution code:
X  = int(input())
temp = X
ret = repr(X) + ':'
for cnt in range(2, X):
    while temp % cnt == 0:
        temp = temp / cnt
        ret += ' ' + repr(cnt)
    cnt += 1
print(ret)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    primes = []

    factor = 2
    while True:
        if n == 1:
            break

        if n % factor == 0:
            n //= factor
            primes.append(factor)
            continue
        else:
            factor += 1

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



main()

Submission status: Wrong Answer

Solution code:
import math

n = m = int(raw_input())
r = int(math.sqrt(n))
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
 
prime=[]
for i in range(r):
    if p[i]:
        prime.append(i+1)

a = []
for i in range(len(prime)):
    if n % prime[i] == 0:
        j = prime[i]
        while n % j == 0:
            n /= j
            a.append(j)

print str(m)+":"," ".join(map(str, a))

Submission status: Wrong Answer

Solution code:
import math

n = m = int(raw_input())
r = int(math.sqrt(n))
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
 
prime=[]
for i in range(r):
    if p[i]:
        prime.append(i+1)

a = []
for i in range(len(prime)):
    if n % prime[i] == 0:
        j = prime[i]
        while n % j == 0:
            n /= j
            a.append(j)

print str(m)+":",n if n == m else str(m)+":"," ".join(map(str, a))

Submission status: Wrong Answer

Solution code:
import math

n = m = int(raw_input())
r = int(math.sqrt(n))
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
 
prime=[]
for i in range(r):
    if p[i]:
        prime.append(i+1)

a = []
for i in range(len(prime)):
    if n % prime[i] == 0:
        j = prime[i]
        while n % j == 0:
            n /= j
            a.append(j)
if n == m:
    print str(m)+":",m
else:
    print str(m)+":"," ".join(map(str, a))

Submission status: Wrong Answer

Solution code:
import math

n = m = int(raw_input())
r = int(math.sqrt(n))+1
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
 
prime=[]
for i in range(r):
    if p[i]:
        prime.append(i+1)

a = []
for i in range(len(prime)):
    if n % prime[i] == 0:
        j = prime[i]
        while n % j == 0:
            n /= j
            a.append(j)
if n == m:
    print str(m)+":",m
else:
    print str(m)+":"," ".join(map(str, a))

Submission status: Wrong Answer

Solution code:
import math
 
n = m = int(raw_input())
r = int(math.sqrt(n))
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
  
prime=[]
for i in range(r):
    if p[i]:
        prime.append(i+1)

a = []
for i in range(len(prime)):
    if n % prime[i] == 0:
        a.append(prime[i])
        n /= prime[i]
        
if n != 1:
    a.append(n)

count = 0
for i in range(m):
    flag = 1
    for j in a:
        if i%j == 0:
            flag = 0
            break
    if flag == 1:
        count += 1

print count

Submission status: Time Limit Exceeded

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

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)))

Submission status: Time Limit Exceeded

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

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: Time Limit Exceeded

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

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

for i in range(2, n+1):
    while n%i == 0:
        n = n/i
        L.append(i)
        #print(' ' + str(i), end = '')

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

Submission status: Time Limit Exceeded

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

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

for i in range(2, n+1):
    while n%i == 0:
        n = n/i
        print(' ' + str(i), end = '')

print()

        #L.append(i)
        
#print(' '.join(map(str, L)))

Submission status: Time Limit Exceeded

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 <= N:
    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: Time Limit Exceeded

Solution code:
def fact(num):
  ret=[]
  if num==2:
    ret=[2]
    return ret
  elif num==3:
    ret=[2,3]
    return ret
  while 1:
    for i in range(2,int(num**0.5)+1):
      if num%i==0:
        ret.append(i)
        num=num%i
        break
 
n=int(input())
ans=fact(n)
print('{}: {}'.format(n,' '.join(map(str,ans))))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
num=n
if n==2:
  prime=[2]
elif n==3:
  prime=[2,3]
else:
  prime=[]
  for _ in range(40):
    for i in range(2,n+1):
      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: Time Limit Exceeded

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(n)
    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: Time Limit Exceeded

Solution code:
from itertools import count
n = input()
l = []
l += [str(n) + ":"]
while 1:
    if n == 1:break
    for i in count(2):
        if n % i == 0:
            n /= i
            l += [i]
            break
print " ".join(map(str,l))

Submission status: Time Limit Exceeded

Solution code:
n = input()
l = []
l += [str(n) + ":"]
while 1:
    if n == 1:break
    for i in xrange(2,n+1):
        if n % i == 0:
            n /= i
            l += [i]
            break
print " ".join(map(str,l))

Submission status: Time Limit Exceeded

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 > n:
        break
    while not (n % p):
        n = n // p
        a.append(p)

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

Submission status: Time Limit Exceeded

Solution code:
def find_divisors(n):
    divisors = []
    d = 2
    while n > 1:
        while n % d == 0:
            divisors.append(d)
            n //= d
        d += 1
    return divisors


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

    # ?¨?????????????
    results = find_divisors(target_number)

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

Submission status: Time Limit Exceeded

Solution code:
def factorize(n):
    p = n
    while True:
        if p % 2 == 0:
            p //= 2
            yield 2
        else:
            break

    for i in range(3,n+1,2):
        while True:
            if p % i == 0:
                p //= i
                yield i
            else:
                break

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

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

Submission status: Time Limit Exceeded

Solution code:
def factorize(n):
    p = n
    while True:
        if p % 2 == 0:
            p //= 2
            yield 2
        else:
            break

    r = 3
    while p != 1:
        if p % r == 0:
            p //= r
            yield r
        else:
            r += 2

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

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

Submission status: Time Limit Exceeded

Solution code:
def factorize(n):
    p = n
    while True:
        if p % 2 == 0:
            p //= 2
            yield 2
        else:
            break

    r = 3
    while p >= r:
        if p % r == 0:
            p //= r
            yield r
        else:
            r += 2

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

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

Submission status: Time Limit Exceeded

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

n = int(input())
print(n,':',sep='',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-1:
            count += 1
            break
    if count == 5:
        break
array.append(n)
for i in range(len(array)):
    print(array[i],end=' ')
print('')

Submission status: Time Limit Exceeded

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

n = int(input())
print(n,':',sep='',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-1:
            count += 1
            break
    if count == 10:
        break
array.append(n)
for i in range(len(array)):
    print(array[i],end=' ')
print('')

Submission status: Time Limit Exceeded

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

n = int(input())
print(n,':',sep='',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-1:
            count += 1
            break
    if count == 15:
        break
array.append(n)
for i in range(len(array)):
    print(array[i],end=' ')
print('')

Submission status: Time Limit Exceeded

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

while True:
    n = int(input())
    print(n,':',sep='',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-1:
                count += 1
                break
        if count == 15:
            break
    array.append(n)
    for i in range(len(array)):
        print(array[i],end=' ')
        print('')

Submission status: Time Limit Exceeded

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

while True:
    n = int(input())
    print(n,':',sep='',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-1:
                count += 1
                break
        if count == 15:
            break
    array.append(n)
    for i in range(len(array)):
        print(array[i],end=' ')
    print('')

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
n = int(input())
print(':',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-1:
            count += 1
            break
    if count == 15:
        break
array.append(n)
for i in range(len(array)):
    print(array[i],end=' ')
print('')

Submission status: Time Limit Exceeded

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-1:
            count += 1
            break
    if count == 15:
        break
array.append(n)
for i in range(len(array)):
    print(array[i],end=' ')
print('')

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
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)):
    print(' ',array[i],sep = '',end='')
print('')

Submission status: Time Limit Exceeded

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

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 == 12:
        break
array.append(n)
for i in range(len(array)):
    print(' ',array[i],sep = '',end='')
print('')

Submission status: Time Limit Exceeded

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

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 == 5:
        break
array.append(n)
for i in range(len(array)):
    print(' ',array[i],sep = '',end='')
print('')

Submission status: Time Limit Exceeded

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

res=[]
i = 2
while i <= (orig_n):
    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: Time Limit Exceeded

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
if len(res) == 0 : res.append(orig_n)
print("{0}: {1}".format(orig_n, " ".join(map(str, res))))