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 1.8 Program Works fine in console and eclipse but gives wrong answer
Posted by Sohan Agate 13 Mar 2016 00:34
Program is in Java 1.8 but gives wrong answer on the timus server. Any help will be appreciated. Thanks a lot.

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class ReverseRoot {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        List<Long> list = new ArrayList<Long>();
        while ( in.hasNextLong() ) {
            long l = in.nextLong();
            list.add(l);
        }
        DecimalFormatSymbols s = new DecimalFormatSymbols();
        s.setDecimalSeparator('.');
        DecimalFormat df = new DecimalFormat("#,####0.0000",s);
        for (int i = list.size() - 1; i >= 0; --i) {
            out.println(df.format(Math.sqrt(list.get(i))));
            out.flush();
        }

    }
}