


https://www.acmicpc.net/problem/1436
import java.io.*;
class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(solve(Integer.parseInt(br.readLine())));
}
static int solve(int N) {
int num = 666;
int count = 0;
while (true) {
if (count == N) {
return num - 1;
}
String str = String.valueOf(num);
if (str.contains("666")) {
count++;
}
num++;
}
}
}
666, 1666, 6661 등이 있다.666을 시작으로 while문을 통해 숫자를 1씩 증가시킨다.666이 들어있다면, count를 증가시킨다.666이 들어가는 숫자중 작은 숫자부터 구하면 되는 문제이기 때문에, 규칙을 찾고 적용해가면서 문제를 해결하려고 하였다.666만 있으면 되기 때문에 이를 중점적으로 생각하면 간단히 풀릴 줄 알았으나 큰 오산이었다.