|
|
вернуться в форумHelp me with test #8!!! here my program Please, help me with this problem. I don't know why WA. here my program (JAVA): import java.util.Scanner; public class Solution implements Runnable{ Scanner in;
public void run(){ try{ in = new Scanner (System.in); int n1 = in.nextInt(); int n = n1; if (n == 0){ System.out.print(10); } else{ if (n == 1){ System.out.print(n); } else{ int[]mass = new int [n1];
for (int i = 0; i < n1; i++){ mass[i] = 0; }
int j = 0;//указатель массива mass
for (int i = 9; i > 1; i--){ boolean f = true; while (f){ if (n % i == 0){ n = n / i; mass[j] = i; j++; //System.out.print(i + " "); } if (n % i != 0){ f = false; } } } if (n >= 11){ System.out.print(-1); } else{ for (int i = n1 - 1; i >= 0; i--){ if (mass[i] != 0){ System.out.print(mass[i]); } } } } }
} catch( Exception er){ er.printStackTrace(); System.exit(-1); } }
public static void main(String[] args) { new Thread (new Solution()).start(); } } |
|
|