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

Why crash ? Help please
Posted by Lai Manh Tuan 1 Dec 2012 11:38
import java.util.Scanner;
import java.text.*;
public class Main
{
    public static void main (String [] args)
    {
        Scanner kb = new Scanner (System.in);
        DecimalFormat df = new DecimalFormat("#.0000");
        int dem = 0;
        String inra;
        double [] data = new double [50000];
        while (kb.hasNextDouble())
        {
            data[dem] = kb.nextDouble ();
            dem++;
        }
        for (int i = dem-1; i >= 0; i--)
        {
            inra = df.format (Math.sqrt(data[i]));
            if (inra.charAt (0) == '.')
                inra = "0" + inra;
            System.out.println (inra);
        }

    }
}
Re: Why crash ? Help please
Posted by DuongThanh Nguyen 25 Jan 2013 22:04
I used
List<Double> = new ArrayList<Double>();

and it worked without crash.

----

public class Main
{
    public static void main (String [] args)
    {
...

        String inra;
        List<Double> coll = new ArrayList<Double>();

        while (kb.hasNextDouble())
        {
            coll.add(kb.nextDouble());
        }

        for(int j = coll.size() - 1; j >= 0; j--)
        {
            inra = df.format (Math.sqrt(coll.get(j)));
            if (inra.charAt (0) == '.')
                inra = "0" + inra;
            System.out.println (inra);
        }

    }
}

----

or following will work
double [] data = new double [140000];

Edited by author 25.01.2013 22:05

Edited by author 25.01.2013 22:05

Edited by author 25.01.2013 22:41
Re: Why crash ? Help please
Posted by Your_Y 2 Feb 2013 14:57
FUCK??????