최대 1 분 소요

Question

1436Q


Solution

  • 숫자 666 부터 1씩 증가시켜 666이 있으면 count를 증가 시킨다
  • 증가된 count와 input이 같으면 출력

Cord

#include <iostream>

using namespace std;

int main()
{
	int start = 666;
	int count = 0;

	// 입력
	int input;
	cin >> input;


	while (true)
	{
		// 숫자 666부터 1씩 증가하여 탐색
		int temp = start;
		while (temp > 0)
		{
			// 숫자안에 666이 있는지 확인
			if (temp % 1000 == 666)
			{
				count++;
				break;
			}
			temp /= 10;
		}

		// input 숫자를 찾으면 출력
		if (count == input)
		{
			cout << start;
			return 0;
		}

		start++;
	}

	return 0;
}

Result

1436


이로써 부루트 포스 Level10 다섯문제가 끝났다.
이 알고리즘은 모든 경우의 수를 확인한다는 전제가 있어 쉬운편이었던 것 같다.