fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int m, n;
  11. m = in.nextInt();
  12. n = in.nextInt();
  13. double[] a = new double[m*n+1];
  14. double sum1 = 1, sum2 = 1, sum3 = 1;
  15. for (int i = 1; i <= m*n; i++)
  16. {
  17. a[i] = in.nextDouble();
  18. if (i <= m)
  19. {
  20. sum1 *= a[i];
  21. }
  22. if ((i > m) && (i <= 2*m))
  23. {
  24. sum2 *= a[i];
  25. }
  26. if ((i > (n - 1)*m) && (i <= n*m))
  27. {
  28. sum3 *= a[i];
  29. }
  30. }
  31. System.out.println(sum1 + sum2 + sum3);
  32. }
  33. }
Success #stdin #stdout 0.14s 31480KB
stdin
3 2
1.1 2.2 3.3 4.4 5.5 6.6
stdout
327.426