knyazer

Untitled

Apr 21st, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. import static java.lang.Integer.max;
  4. import static java.lang.Integer.min;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9. Scanner in = new Scanner(System.in);
  10. int N = in.nextInt(), x = in.nextInt(), y = in.nextInt();
  11.  
  12. int mx = max(x , y);
  13. int mn = min(x, y);
  14.  
  15. int timer = mn;
  16. int ready = 0;
  17. while (ready < N) {
  18. if (timer % mn == 0) ready += 1;
  19. if ((timer - mn) % mx == 0) ready += 1;
  20. timer += 1;
  21. }
  22.  
  23. System.out.println(timer);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment