|  | 
|  | 
| вернуться в форум | Problem at the Java My code timeLimitexit  9-test.I not understanding where is mistak.Help me programmists.Down my code.
 
 
 import java.util.Scanner;
 import java.io.IOException;
 import java.io.PrintWriter;
 public class File{
 public static void main(String[] args)throws IOException{
 Scanner sc=new Scanner(System.in);
 PrintWriter pw=new PrintWriter(System.out);
 double[] a=new double[150000];
 int n=0;
 while(sc.hasNext())
 a[n++]=sc.nextDouble();
 while(n>0)
 pw.println(String.format("%.4f",Math.sqrt(a[--n])));
 pw.close();
 }
 }
Re: Problem at the Java String.format("%.4f",Math.sqrt(a[--n])) is a bottleneck for your solution. Let try using BigDecimal and when you want to format number to 4 digits just call setScale.Re: Problem at the Java Thank you!!!
 
 | 
 | 
|