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 1023. Buttons

JAVA - What's wrong with my solution (Crashed)
Posted by JOLO_ 16 Aug 2012 01:38
public class Buttons {
    public static void main(String[] args) {
        //convert parameter into int
        int N = 0;
        try {
            N = Integer.parseInt(args[0]);
        } catch(NumberFormatException ignore) {}
        //find L
        for(int i = 3; i < Math.sqrt(N); i++) {
          if(N%i == 0) {
            System.out.println(i-1);
        System.exit(1);
          }
    }
    System.out.println(N-1);
    }
}
P.S. On my computer it works perfectly
Re: JAVA - What's wrong with my solution (Crashed)
Posted by Noob 16 Aug 2012 02:27
Numbers are read from stdin