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 1001. Reverse Root

Java. Test 4. Error
Posted by Vladimir Usychenko 16 Oct 2012 02:11
    public static void main(String[] args) throws Exception {

        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = null;

        List<Long> listLong = new ArrayList<Long>();
        while (true) {
            try {
                listLong.add(readLong());
                if (!in.ready()) {
                    throw new Exception();
                }
            }
            catch(Exception ex) {
                break;
            }
        }
        for (int i = listLong.size() - 1; i >= 0; i--) {
            Double dbl = (double)listLong.get(i);
            BigDecimal bigDecimal = new BigDecimal(Math.sqrt(dbl));
            bigDecimal = bigDecimal.setScale(4, BigDecimal.ROUND_HALF_UP);
            out.println(bigDecimal.toPlainString());
        }
        out.flush();
    }

It fails on a test №4. Does somebody know why?
Re: Java. Test 4. Error
Posted by Alexander 2 Feb 2013 05:37
public class Main {
    public static void main(String[] args){


          Scanner in = new Scanner(System.in);
          PrintWriter out = new PrintWriter(System.out);
          ArrayList<Long> l=new ArrayList<Long>();
          try{
          while(in.hasNext()){
              l.add(in.nextLong());
          }
          }
          catch(Exception e){}
          finally{
              in.close();
          }

    }

}
maybe use,correct read? Long type