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

Java Time limit exceeded
Posted by ManYang 12 Sep 2012 08:55
my code do not have compile error, but it still can not work, I do not know where went wrong.


import java.lang.*;
import java.util.*;
/**
 *
 * @author manyang
 */
public class Timus_1001 {
//create a arraylist from input
//donot konw how to play with arraylist, use a array
    public static void main(String[] args){
        double num[] = new double[10000];//10000 is not precise, should determined by 256kb
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int i = 0;
            double result = Math.sqrt(sc.nextDouble());
            num[i] = result;
            i++;
        }
/*for arraylist, use arrayName.length
 output reversely
 calc each
 for array, use num[i]
 */
        for (int i = num.length - 1; i >=0; i--) {

            System.out.printf("%.4f", num[i]);
            System.out.println();
        }
    }

}