본문 바로가기
알고리즘/백준 BOJ

[ BOJ/C# ] 1436 영화감독 숌

by 왹져박사 2023. 10. 22.
728x90

https://www.acmicpc.net/problem/1436

 

1436번: 영화감독 숌

666은 종말을 나타내는 수라고 한다. 따라서, 많은 블록버스터 영화에서는 666이 들어간 제목을 많이 사용한다. 영화감독 숌은 세상의 종말 이라는 시리즈 영화의 감독이다. 조지 루카스는 스타워

www.acmicpc.net

처음에는 이해가 잘 안 갔는데, 찬찬히 읽어보면 문제는 666이 들어가는 가장 작은 수대로 카운트하면 해결할 수 있었다. 

using System;
using System.IO;

namespace B1436
{
    class Program
    {
        static void Main()
        {
            StreamReader sr = new StreamReader(Console.OpenStandardInput());
            StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());

            int n = int.Parse(sr.ReadLine());
            int count = 0;
            int end = 666;

            while (true)
            {
                if (Convert.ToString(end).Contains("666")) count++;
                if (n == count) break;
                end++;
            }
            sw.Write(end);
            sr.Close();
            sw.Flush();
            sw.Close();
        }
    }
}

728x90