코드포스 460A (codeforces 460A)

코드포스 460A (codeforces 460A) 문제 풀이 및 코드 (description and code)

Problem - 460A - Codeforces

코드

import java.io.*;

public class CF460A {
    static int n, m, count = 0, t = 1;
    static String ins[];
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        ins = br.readLine().split(" ");
        n = Integer.parseInt(ins[0]);
        m = Integer.parseInt(ins[1]);
        while (n != 0) {
            n += (t == m) ? 1 : 0;
            t = (t == m) ? 1 : t + 1;
            count++;n--;
        }
        bw.write(count + "\n");
        bw.flush();bw.close();

    }
}

설명