[백준] 영화감독 숌 1436번

나의 풀이

public class DirectorSyom {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        int titles = 666;
        int count = 1;

        while(count != N) {
            titles++;

            if(String.valueOf(titles).contains("666")) {
                count++;
            }
        }

        System.out.println(titles);
    }
}
  • N의 수를 입력받고 666부터 1씩 증가하면서 카운트를 셀 것이다.
  • 첫 스타트가 666이기 때문에 카운트는 1로 두고 while문을 돌린다.
  • 단, 하나하나 세기 때문에 너무 오래걸렸다.

0개의 댓글