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

Time limit exceeded. Help! (Java)
Posted by Lendon 7 Mar 2010 15:55
I don't know how to correct my program for more speedly work. Help anybody.
import java.util.*;
import java.math.*;

public class InvertedSqrt
{
    public static void main(String []args)
    {
    Scanner scan = new Scanner(System.in);
    ArrayList<BigInteger> input = new    ArrayList<BigInteger>();
    input.add(scan.nextBigInteger());
    while(scan.hasNextBigDecimal() && input.size() * Integer.SIZE <= 256 * 1024 * 1024)
    {
    input.add(scan.nextBigInteger());
    }
    scan.close();
    int i = input.size() - 1;
        while(i >=0)
        {
        System.out.printf("%.4f",java.lang.Math.sqrt(input.get(i).doubleValue()));
        System.out.print("\n");
        i--;
        }
    }
}
Re: Time limit exceeded. Help! (Java)
Posted by SKYDOS 7 Mar 2010 18:58
in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
      out = new PrintWriter(new OutputStreamWriter(System.out));
Lendon wrote 7 March 2010 15:55
I don't know how to correct my program for more speedly work. Help anybody.
import java.util.*;
import java.math.*;

public class InvertedSqrt
{
    public static void main(String []args)
    {
    Scanner scan = new Scanner(System.in);
    ArrayList<BigInteger> input = new    ArrayList<BigInteger>();
    input.add(scan.nextBigInteger());
    while(scan.hasNextBigDecimal() && input.size() * Integer.SIZE <= 256 * 1024 * 1024)
    {
    input.add(scan.nextBigInteger());
    }
    scan.close();
    int i = input.size() - 1;
        while(i >=0)
        {
        System.out.printf("%.4f",java.lang.Math.sqrt(input.get(i).doubleValue()));
        System.out.print("\n");
        i--;
        }
    }
}
Re: Time limit exceeded. Help! (Java)
Posted by SKYDOS 7 Mar 2010 18:59
use double, but not BigInteger