쵼쥬 2021. 11. 22. 13:22


내 코드

package com.company;

import java.io.*;
import java.util.*;

public class Main {
    static double N, M;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        N = Double.parseDouble(st.nextToken());
        M = Double.parseDouble(st.nextToken());

        double x = N * M;
        int count = 0;

        while (x > 0) {
            x -= N;
            if (x % M != 0) {
                count++;
            }
        }
        System.out.println(count);

    }
}