Hard deck/Module

External Module and Access Opener

서버관리자 페페 2022. 8. 4. 12:52
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        // Input Supply Cable
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();

        for (int i = 0; i < T; i++) {

            // Preprocessing
            int A = sc.nextInt();
            int B = sc.nextInt();

            // Operating LCM
            int result = A*B / GCD(A, B);

            // Output Extracting Cable
            System.out.println(result);
        }
    }

    // External Module
    public static int GCD(int A, int B) {
        if (B == 0)
            return A;
        else
            return GCD (B, A%B);
    }
}

 

'Hard deck > Module' 카테고리의 다른 글

Extended Euclidean  (0) 2022.08.04
Euclidean  (0) 2022.08.04
(O.E Cable) BufferedWriter  (0) 2022.08.04
A * B = GCD(A, B) * LCM(A, B)  (0) 2022.08.04
000 : Split Split  (0) 2022.07.30