[백준] 1406: 에디터
2020. 12. 29. 01:44
Problem set
1406번: 에디터 첫째 줄에는 초기에 편집기에 입력되어 있는 문자열이 주어진다. 이 문자열은 길이가 N이고, 영어 소문자로만 이루어져 있으며, 길이는 100,000을 넘지 않는다. 둘째 줄에는 입력할 명령어의 개수 www.acmicpc.net #include #include #include int main() { using namespace std; ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); string input_str; cin >> input_str; stack cursor_left, cursor_right; for (char& ch : input_str) { cursor_left.push(ch); } int t; ..
[백준] 1373: 2진수 8진수
2020. 12. 29. 01:42
Problem set
1373번: 2진수 8진수 첫째 줄에 2진수가 주어진다. 주어지는 수의 길이는 1,000,000을 넘지 않는다. www.acmicpc.net #include #include using namespace std; auto main()->int { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); string in; cin >> in; int n = in.size(); if (n % 3 == 1) { cout
[백준] 1212: 8진수 2진수
2020. 12. 29. 01:40
Problem set
1212번: 8진수 2진수 첫째 줄에 8진수가 주어진다. 주어지는 수의 길이는 333,334을 넘지 않는다. www.acmicpc.net #include #include #include using namespace std; string eight[8] = {"000","001","010","011","100","101","110","111"}; int main(){ string s; cin >> s; bool start = true; if (s.length() == 1 && s[0]-'0' == 0) { cout
[백준] 1158: 요세푸스 문제
2020. 12. 29. 01:38
Problem set
1158번: 요세푸스 문제 첫째 줄에 N과 K가 빈 칸을 사이에 두고 순서대로 주어진다. (1 ≤ K ≤ N ≤ 5,000) www.acmicpc.net #include #include using namespace std; int main() { int n, m; scanf("%d %d",&n,&m); queue q; for (int i=1; i
[백준] 1110: 더하기 사이클
2020. 12. 29. 01:36
Problem set
1110번: 더하기 사이클 0보다 크거나 같고, 99보다 작거나 같은 정수가 주어질 때 다음과 같은 연산을 할 수 있다. 먼저 주어진 수가 10보다 작다면 앞에 0을 붙여 두 자리 수로 만들고, 각 자리의 숫자를 더한다. 그 다음, www.acmicpc.net #include #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int ini_num; cin >> ini_num; int cnt = 0; int num; while (true){ if (cnt == 0) { num = ini_num; } int digit_1 = num % 10; int dig..
[백준] 1065: 한수
2020. 12. 29. 01:34
Problem set
1065번: 한수 어떤 양의 정수 X의 각 자리가 등차수열을 이룬다면, 그 수를 한수라고 한다. 등차수열은 연속된 두 개의 수의 차이가 일정한 수열을 말한다. N이 주어졌을 때, 1보다 크거나 같고, N보다 작거나 www.acmicpc.net #include #include using namespace std; int nofhan(const int& n) { int res = 0; if (n = 100 && n = 100) { int mid = mid_ini; int a[3] = {}; int idx = 0; while (mid ..