#10849: 參考AC:JAVA


0406229 (Js29)


import java.util.Scanner;

public class JAVA {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int s;
		
		while(sc.hasNextInt()){
			
			s=sc.nextInt();
			
			int i=2;
			boolean first=true;
			do{
				
				int c=0;
				while(s%i==0){
					c++;
					s/=i;
				}
				if(c>0){
					if(first){
						System.out.print( i + (c==1?"":("^"+c)) );
						first=false;
					}else{
						System.out.print( " * " + i + (c==1?"":("^"+c)) );
					}
				}
				
				i++;
			}while(s!=1);
			System.out.println();
		}
	}
}