https://www.acmicpc.net/problem/1436
브루트포스 알고리즘을 사용했다.
첫 번째 종말의 수는 666이기 때문에
666에서 숫자를 1씩 키워가며 숫자를 문자열로 표현했을 때 "666"을 포함하는지 검사하고
포함할 경우 cnt를 1 증가시켰다.
cnt가 n과 같아지면 break로 반복문을 빠져나온다.
package com.ll;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int cnt = 0;
int num = 666;
while(true) {
if(String.valueOf(num).contains("666")) {
cnt++;
}
if(cnt == n) {
break;
}
num++;
}
System.out.println(num);
}
}