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

Getting Restricted Function for Problem 1001.Reverse Root
Posted by raoviswanath 15 Dec 2015 18:29
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.Stack;

public class ReverseRoot {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new FileReader("Test.txt"));
        Stack<Double> stack = new Stack<Double>();
        String str;
        while((str = br.readLine()) != null)
        {
            String[] tokens = str.trim().replaceAll("\\s+", " ").split(" ");
            for(String st : tokens)
            {
                if(!st.equals(""))
                    stack.push(Double.parseDouble(st));
            }
        }

        br.close();

        final String decimalFormatStr = "0.0000";
        DecimalFormat df = new DecimalFormat(decimalFormatStr);
        while(stack.size() != 0)
        {
            System.out.println(df.format(Math.sqrt(stack.pop())));
        }

    }

}
Re: Getting Restricted Function for Problem 1001.Reverse Root
Posted by ToadMonster 15 Dec 2015 21:08
> BufferedReader br = new BufferedReader(new FileReader("Test.txt"));

http://acm.timus.ru/help.aspx?topic=judge
The program must be a console application.
Input data must be read from the standard input (input from the keyboard). Output data must be printed to the standard output (screen output).
Re: Getting Restricted Function for Problem 1001.Reverse Root
Posted by raoviswanath 16 Dec 2015 09:58
Thanks a lot for pointing the issue.
I will change the implementation and repost it.