|
|
вернуться в форумTime limit exceeded. Help! (Java) Послано Lendon 7 мар 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) Послано SKYDOS 7 мар 2010 18:58 in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); 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) Послано SKYDOS 7 мар 2010 18:59 use double, but not BigInteger |
|
|