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

Solution in JAVA (judge verdict: Runtime Error)

import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int n;
    boolean[] p;

    void run(){
	p = new boolean[100000000];
	setP();
	while(sc.hasNext()){
	    int n = sc.nextInt();
	    if(n>=2){
		System.out.print(n+":");
		solve(n);
	    }
	}
    }

    void solve(int n){
	int i=2;
	while(n>1){
	    while(p[i] && n%i==0){
		n = n/i;
		System.out.print(" "+i);
	    }
	    if(i>2) i+= 2;
	    else i++;
	}
	System.out.println();
    }

    void setP(){
	Arrays.fill(p, true);
	p[0] = p[1] = false;
	for(int i=2; i<p.length; i++){
	    if(p[i])
		for(int j=i*2; j<p.length; j+=i)
		    p[j] = false;
	}
    }
}