Notice
Recent Posts
Recent Comments
07-03 00:01
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

Byeol Lo

N11653 - 소인수분해 본문

Algorithm/Math

N11653 - 소인수분해

알 수 없는 사용자 2024. 6. 22. 17:40

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

public class Main {
    final static BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
    final static BufferedWriter BW = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        int to = Integer.parseInt(BR.readLine());
        int tmp = to, divisor = 2;

        while (tmp != 1) {
            while (tmp % divisor == 0) {
                tmp /= divisor;
                BW.write(Integer.toString(divisor));
                BW.write("\n");
            }
            divisor++;
        }
        BW.close();
        BR.close();
    }
}

'Algorithm > Math' 카테고리의 다른 글

N1193 - 분수찾기  (0) 2024.06.22
N2903 - 중앙 이동 알고리즘  (0) 2024.06.15
N13241 - 최소공배수 구하기  (0) 2024.06.15
Comments