백준 1436 영화감독 숌 ❌

CJB_ny·2023년 1월 19일
0

백준

목록 보기
58/104
post-thumbnail

영화감독 숌

오늘 4시간? 조금 넘게 걸린거같다. (못 품)

거의 근접하게 푼거같은데 일단 틀림.

내코드 (틀린건데 어디가 틀린지 모르겠다)


이런 문제는 일단 "무식"하게 풀 생각부터 해야한다.

먼저 "완전 탐색"으로 풀 수 있는가? 생각을 먼저하고

그다음 "DP"를 생각을 하고

그다음에 "그리디"를 생각을 해야한다.

예를 들어 "sorted 된 배열"이다. 라고 생각이 되면은

"이분탐색"을 사용하거나 하는식의 로직이 필요하다.

강의 코드

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define endl "\n"

int n, v = 666;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n;
	for (;; ++v)
	{
		if (to_string(v).find("666") != string::npos) --n;
		if (n == 0) break;
	}

	cout << v << endl;

	return 0;
}
profile
https://cjbworld.tistory.com/ <- 이사중

0개의 댓글