Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import static java.lang.Integer.max;
- import static java.lang.Integer.min;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int N = in.nextInt(), x = in.nextInt(), y = in.nextInt();
- int mx = max(x , y);
- int mn = min(x, y);
- int timer = mn;
- int ready = 0;
- while (ready < N) {
- if (timer % mn == 0) ready += 1;
- if ((timer - mn) % mx == 0) ready += 1;
- timer += 1;
- }
- System.out.println(timer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment