fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. float k = in.nextInt(), n = in.nextInt(), m = in.nextInt(), d = in.nextInt(), s = (d * k * n * m) / (k * n * m - k * m - k * n - m * n);
  11. if ((1 / k + 1 / n + 1 / m >= 1) | (Math.floor(s / k) != s / k | Math.floor(s / n) != s / n | Math.floor(s / m) != s / m) | !(Math.floor(s) == s))
  12. System.out.println(-1);
  13. else System.out.println(Math.round(s));
  14. }
  15. }
Success #stdin #stdout 0.07s 2184192KB
stdin
3	2	5	8	
stdout
-1