본문 바로가기

카테고리 없음

[백준 11653 c++ V] 소인수분해

728x90
반응형

https://github.com/xhaktmchl/Algorithm_study/blob/main/BOJ/%EC%88%98%ED%95%99(Math)/%5B%EB%B0%B1%EC%A4%80%2011653%20c%2B%2B%20V%5D%20%EC%86%8C%EC%9D%B8%EC%88%98%EB%B6%84%ED%95%B4.cpp 

 

GitHub - xhaktmchl/Algorithm_study: 알고리즘 이론 및 문제풀이

알고리즘 이론 및 문제풀이. Contribute to xhaktmchl/Algorithm_study development by creating an account on GitHub.

github.com

#include <iostream>
#include <algorithm>
//#include <map> // 중복 x 
//#include <string> // getline
#include <vector>
using namespace std;
/*
[백준 11653 c++ V] 소인수분해
문제: 
접근1: 
시간복잡도: 
풀이:
    //1.입력
    //3.소인수 분해
*/
int n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    //1.입력
    cin >> n;
    //2.소인수 분해
    for (int i = 2; i <= n; i++) {
        while (n % i == 0) {
            cout << i << '\n';
            n /= i;
        }
    }
    return 0;
}
반응형