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

what's wrong with my implementation (java)
Posted by lhyx1990 13 Dec 2013 08:52
import java.util.*;
import java.io.*;
public class p1001 {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        ArrayList<String> nums = new ArrayList<String>();
        String line;
        while (true) {
            line = br.readLine();
            if (line == null) break;
            StringTokenizer st = new StringTokenizer(line);
            while (st.hasMoreTokens()) {
                nums.add(st.nextToken());
            }
        }

        for (int i = nums.size() - 1; i >= 0; i--) {
            int num = Integer.parseInt(nums.get(i));
            System.out.printf("%.4f\n", Math.sqrt(num));
        }
    }
}
Re: what's wrong with my implementation (java)
Posted by Gary 14 Dec 2013 16:04
you did not account for the max size limit on the input....