Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Why WA ?????????? why ?? in java....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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator