|
|
back to boardJava 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(); } }
}
|
|
|