ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1014. Product of Digits

Help me with test #8!!! here my program
Posted by nikenny 2 Sep 2009 13:52
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();

    }

}