fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int n,m;
  13. Scanner in = new Scanner(System.in);
  14. n=in.nextInt();
  15. m=in.nextInt();
  16. double [][] A = new double [n][m];
  17. for (int i=0; i<n; i++){
  18. for (int j=0; j<m; j++){
  19. A[i][j]=in.nextDouble();
  20. }
  21. }
  22. for (int i = 0; i < n; i++){
  23. for (int j = 0; j < m; j++){
  24. if (A[i][j]!=0){
  25. A[i][j]=-(1/A[i][j]);
  26. }
  27. }
  28. }
  29. for (int i = 0; i < n; i++){
  30. for(int j = 0; j < m; j++){
  31. System.out.printf("%.6f ",A[i][j]);
  32. }
  33. System.out.println();
  34. }
  35. }
  36. }
Success #stdin #stdout 0.17s 321280KB
stdin
3
4
2 0 3 6
1 0 1 2
9 0 7 8
stdout
-0.500000 0.000000 -0.333333 -0.166667 
-1.000000 0.000000 -1.000000 -0.500000 
-0.111111 0.000000 -0.142857 -0.125000