Baekjoon 1436.영화감독 슘 c++ [Silver V]
·
Baekjoon/Silver
브루트 포스시간을 줄이려고 666이 포함되어 있는 숫자만 골라내도록 했음#include #include using namespace std;int check(int N){ int count = 0; int number = 666; while (true) { if (to_string(number).find("666") != string::npos) { count++; if (count == N) { return number; } } number++; }}int main(){ int N; cin >> N; cout
Baekjoon 17219.비밀번호 찾기 c++ [Silver IV]
·
Baekjoon/Silver
단순 구현#include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N, M; cin >> N >> M; unordered_map sites; while (N--) { string site, password; cin >> site >> password; sites[site] = password; } while (M--) { string find_site; cin >> find_site; if (sites..
Baekjoon 11399.ATM c++[Silver IV]
·
Baekjoon/Silver
단순 구현#include #include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >> N; vector times; for (int i = 0; i > t; times.push_back(t); } sort(times.begin(), times.end()); int total = 0; int hap = 0; for (int t : times) { hap += t; total += hap; } cout
Baekjoon 1764.듣보잡 c++[Silver IV]
·
Baekjoon/Silver
단순 구현#include #include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N, M; cin >> N >> M; unordered_set names; vector ans; int count = 0; for (int i = 0; i > unheard_name; names.insert(unheard_name); } for (int i = 0; i > unseened_name; if (names.count(unseened_name)) {..
Baekjoon 11723.집합 c++ [Silver V]
·
Baekjoon/Silver
2가지 방법문제에서 s 배열의 크기가 한정되어 있으므로 배열을 사용해서 해결비트마스크배열#include using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);int M;cin >> M;int s[21] = {0}; while (M--){ string cmd; int x = 0; cin >> cmd; if (cmd == "add") { cin >> x; s[x] = 1; } else if (cmd == "remove") { cin >> x; s[x] = 0; } else if (cmd ==..
Baekjoon 1874.스택 수열 c++ [Silver II]
·
Baekjoon/Silver
c++에 있는 stack을 활용시간 복잡도는 O(n)으로 상당히 좋은 코드#include #include #include #include #include #include using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; cin >> N; vector ans(N); for (int i = 0; i > ans[i]; stack st; string push_and_pop; int current_number = 1; for (int i = 0; i