|
|
вернуться в форумJava 1.8 Program Works fine in console and eclipse but gives wrong answer 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(); }
} } |
|
|