https://www.acmicpc.net/problem/1436
#include <iostream>
#include <string>
#include <climits>
using namespace std;
int main() {
int N; cin >> N;
int count = 0;
for (int i = 666; i < INT_MAX; i++) {
string str = to_string(i);
for (int k = 0; k <= str.size()-3; k++) {
if (str[k] == '6' && str[k + 1] == '6' && str[k + 2] == '6') {
count++;
if (N == count) {
cout << i << endl;
return 0;
}
break;
}
}
}
return 0;
}
'전공공부 > 코딩테스트' 카테고리의 다른 글
(c++) 백준 "10814) 나이순 정렬" (0) | 2022.06.03 |
---|---|
(c++) 백준 "2609) 최대공약수와 최소공배수" (0) | 2022.06.03 |
(c++) 프로그래머스 "가장 긴 펠린드롬" (0) | 2022.06.02 |
(c++) 백준 "2869) 달팽이는 올라가고 싶다" (0) | 2022.06.02 |
(c++) 백준 "2775) 부녀회장이 될테야" (0) | 2022.06.02 |