간단한 문제였다. 왜 LV2 인지 잘 모르겠음.
#include <string>
#include <vector>
using namespace std;
int check(int n) {
if (n == 1)
return 0;
for (int i = 2; i * i <= n; i++)
if (n % i == 0 && n / i <= 10000000)
return n / i;
return 1;
}
vector<int> solution(long long begin, long long end) {
vector<int> answer;
for (int i = begin; i <= end; i++)
answer.push_back(check(i));
if (begin == 1) answer[0] = 0;
return answer;
}'Coding_Test 연습 > Programmers' 카테고리의 다른 글
| [프로그래머스] (C++) LV2 하노이의 탑 (0) | 2022.06.11 |
|---|---|
| [프로그래머스] (C++) LV2 줄 서는 방법 (0) | 2022.06.10 |
| [프로그래머스] (C++) LV2 멀리 뛰기 (0) | 2022.06.09 |
| [프로그래머스] (C++) LV2 쿼드압축 후 개수 세기 (0) | 2022.06.08 |
| [프로그래머스] (C++) LV2 n^2 배열 자르기 (0) | 2022.06.05 |