how to communicate with the judge?

Write here if you have problems with your Java source code

Moderator: Board moderators

how to communicate with the judge?

Postby ahaarrestad » Thu May 20, 2010 5:17 pm

Hi.

I'm trying to learn how to communicate with the judge.... I found the "3n+1" problem suitable for this task.

I keep getting "wrong answer" when using this code:
Code: Select all
   public static void main(String[] args){
      Scanner input = new Scanner(System.in);
      String nextLine = null;
      Scanner line = null;
      while(input.hasNextLine() && (nextLine = input.nextLine()).length()>0){
         line = new Scanner(nextLine);
         long min=0;
         long max=0;
         min=line.nextLong();
         max=line.nextLong();
         int maxLength=0;
         int temp=0;
         long start = System.currentTimeMillis();
         for(long i=min;i<=max;i++){
            temp=count2(i);
            maxLength=Math.max(temp, maxLength);
         }
         long end = System.currentTimeMillis();
         System.out.println(min+" "+max+" "+maxLength);
         System.err.println((end-start)+"ms");
      }
   }

Does any of you know if this should work and it's just my code in "count2" which is giving out the wrong answers? (it does of cause comply with the answers in the text and the timelimit)

regards
Asbjørn Aarrestad
ahaarrestad
New poster
 
Posts: 2
Joined: Thu May 20, 2010 5:13 pm

Re: how to communicate with the judge?

Postby ahaarrestad » Thu May 20, 2010 9:06 pm

Got it.

By looking at the example (http://acm.uva.es/problemset/data/p100.java.html), and the hints on how to start submitting solutions (viewtopic.php?f=1&t=3015) I got it.

* output exactly what they ask (don't swap input parameters)
ahaarrestad
New poster
 
Posts: 2
Joined: Thu May 20, 2010 5:13 pm


Return to Java

Who is online

Users browsing this forum: No registered users and 1 guest