@@ -0,0 +1,1244 @@
+/*%0A * To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage cf;%0A%0Aimport java.util.Stack;%0A%0A/**%0A *%0A * @author debmalyajash%0A */%0Apublic class CodeFighter %7B%0A%0A    /**%0A     * @param args the command line arguments%0A     */%0A    public static void main(String%5B%5D args) %7B%0A        System.out.println(sumOfThrees(%224%22));%0A        System.out.println(sumOfThrees(%2284%22));%0A        System.out.println(sumOfThrees(%22531441%22));%0A        System.out.println(sumOfThrees(%222%22));%0A        System.out.println(sumOfThrees(%225%22));%0A%0A    %7D%0A%0A    public static String sumOfThrees(String n) %7B%0A        long m = Long.parseLong(n);%0A        int i = 0;%0A        StringBuilder sb = new StringBuilder();%0A        Stack%3CInteger%3E s = new Stack%3C%3E();%0A%0A        while (m %3E 0) %7B%0A%0A            long r = m %25 3;%0A            if (r == 2) %7B%0A                return %22Impossible%22;%0A            %7D else if (r != 0) %7B%0A                s.push(i);%0A            %7D%0A            i++;%0A%0A            m /= 3;%0A        %7D%0A%0A        while (!s.isEmpty())%7B%0A            sb.append(3).append(%22%5E%22).append(s.pop()).append(%22+%22);%0A        %7D%0A        return sb.toString().substring(0,sb.length()-1);%0A%0A    %7D%0A%0A%7D%0A

Create CodeFighter.java