eolymp
bolt
Try our new interface for solving problems
Problems

Circle of choirs

published at 4/3/24, 1:07:23 am

import java.util.Scanner;

public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in);

    while (scanner.hasNext()) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        if (gcd(n, m) == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

public static int gcd(int a, int b) {
    while (b != 0) {
        int temp = b;
        b = a % b;
        a = temp;
    }
    return a;
}

}