fork 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 Main
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int N, P, Q, K, flatEntrance, flatFloor, entrance, floor;
  13. Scanner sc = new Scanner(System.in);
  14. N = sc.nextInt();
  15. P = sc.nextInt();
  16. Q = sc.nextInt();
  17. K = sc.nextInt();
  18. flatEntrance = N/P;
  19. flatFloor = N/P/Q;
  20. entrance = K/flatEntrance;
  21. if (K%flatEntrance != 0){
  22. entrance++;
  23. }
  24. if (K%flatEntrance == 0){
  25. floor = Q;
  26. }
  27. else {
  28. floor = (K%flatEntrance)/flatFloor;
  29. if (K%flatFloor != 0){
  30. floor++;
  31. }
  32. }
  33. System.out.format(" %d %d", entrance, floor);
  34. }
  35. }
Success #stdin #stdout 0.14s 321280KB
stdin
250 5 5 1
stdout
Номер парадной: 1 
 Этаж: 1