|
|
back to boardWrong answer in Java why? Posted by Denis 28 Jan 2016 02:11 import java.text.*; import java.util.*; public class Main { public static final int TREAD_MAX_SIZE = 262144; public static void main (String[] args) { DecimalFormatSymbols s = new DecimalFormatSymbols(); s.setDecimalSeparator('.'); DecimalFormat f = new DecimalFormat("0.0000",s); Scanner scan = new Scanner(System.in); int size = 0; String string = ""; while (scan.hasNextLine()) { String line = scan.nextLine(); int sizeline = line.length(); size += sizeline; if (size <= TREAD_MAX_SIZE) { string += line; } else { break; } } scan.close(); double min = 0; double max = Math.pow(10, 18); String[] str = string.trim().split("\\s+"); for (int i = str.length - 1; i >= 0; i--) { Double val = Double.valueOf(str[i]); if (val >= min && val <= max) { val = Math.sqrt(val); System.out.println(f.format(val)); } } } } What's wrong? Code without checking the boundary conditions passed test (0 ≤ Ai ≤ 10^18 and 256КB)! Why? Edited by author 28.01.2016 14:06 |
|
|