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

import java.util.Scanner;
import java.util.*;

public class Main{

    public static void main(String[] args){
        int count=0;
        Map<Integer,Integer> list =new HashMap<Integer,Integer>();
        Scanner sc = new Scanner(System.in);
        int a= sc.nextInt();
        int b=a;
        for(int i=2;i<Math.sqrt(b)+1;i++){
            count=0;
            while(a%i==0){
                count++;
                a/=i;
            }
            if(count!=0) list.put(i,count);
        }
        System.out.print(b+": ");
        for(int figure: list.keySet()){
            if(list.get(figure)==1) System.out.print(figure+" ");
            else System.out.print(figure+" "+list.get(figure)+" ");
        }
        System.out.println();
        }
    }