Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Why WA ?????????? why ?? in java....

Posted by Kylix at 2009-09-10 05:17:22 on Problem 2413
package howmanyfibs;

import java.math.BigInteger;
import java.util.*;
import java.io.*;


public class Main {
  
    public static void main(String[] args) {

   try{     
    int count = 0;
    BigInteger aux = BigInteger.valueOf(1);
    BigInteger cmp = BigInteger.valueOf(0);
    BigInteger []fibs = new BigInteger[481];
    fibs[1] = BigInteger.valueOf(1);
    fibs[2] = BigInteger.valueOf(2);    
      for(int i=3;i<=480;i++)
          fibs[i] = fibs[i-1].add(fibs[i-2]) ;
    
     while( true ){
        
      Scanner cin = new Scanner(System.in);
      String a = cin.next();
      String b = cin.next();
      BigInteger x = new BigInteger(a);
      BigInteger y = new BigInteger(b);
       if(x.compareTo(cmp) == 0 && y.compareTo(cmp) == 0)
            break;
       else
       {   
        
           if( x.compareTo(cmp) == 0 &&  y.compareTo(aux) == 0)
            System.out.printf("%d\n",1);
         else{    
        for(int j=1;j<=480;j++)
        {        
          if( fibs[j].compareTo(x) >= 0 && fibs[j].compareTo(y) <= 0)
              count++;
          }          
          System.out.printf("%d\n",count);
          count = 0;
        
       }
      }
     }
        
    }
   catch(Exception e){}
 }
}





Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator