728x90
반응형
#include <vector>
#include <algorithm>
using namespace std;
int solution(int n) {
vector<int> temp;
for(int i=1; i<n; i++) {
if(n % i == 1) temp.push_back(i);
}
return *min_element(temp.begin(), temp.end());
}
728x90
반응형
'코딩 테스트 > 프로그래머스' 카테고리의 다른 글
[프로그래머스 Level 1, C++] 음양 더하기 (0) | 2022.07.05 |
---|---|
[프로그래머스 Level 1, C++] 포켓몬 (0) | 2022.07.05 |
[Level 1, C++] 완주하지 못한 선수 (0) | 2022.07.04 |
[Level 1, C] 숫자 문자열과 영단어 (0) | 2022.07.04 |
[Level 1, C++] 체육복 (0) | 2022.07.04 |