fork(2) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone {
  6. public static void main (String[] args) {
  7. Scanner x = new Scanner(System.in);
  8. double p = 1, a ;
  9. int c = 0;
  10. while( x.hasNext() ) {
  11. a = x.nextDouble();
  12. if(a >= 0) {
  13. c++;
  14. p*=a;
  15. } else break;
  16. }
  17. System.out.printf("%.2f", Math.pow(p,1.0/c) );
  18. }
  19. }
Success #stdin #stdout 0.17s 321344KB
stdin
1 1 1 -2 4 -6 7
stdout
1.00