오늘 4시간? 조금 넘게 걸린거같다. (못 품)
거의 근접하게 푼거같은데 일단 틀림.
내코드 (틀린건데 어디가 틀린지 모르겠다)
이런 문제는 일단 "무식"하게 풀 생각부터 해야한다.
먼저 "완전 탐색"으로 풀 수 있는가? 생각을 먼저하고
그다음 "DP"를 생각을 하고
그다음에 "그리디"를 생각을 해야한다.
예를 들어 "sorted 된 배열"이다. 라고 생각이 되면은
"이분탐색"을 사용하거나 하는식의 로직이 필요하다.
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define endl "\n"
int n, v = 666;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (;; ++v)
{
if (to_string(v).find("666") != string::npos) --n;
if (n == 0) break;
}
cout << v << endl;
return 0;
}