[BOJ] 1158: 요세푸스 문제
2022. 9. 28. 01:30
알고리즘
문제: https://www.acmicpc.net/problem/1158 #include using namespace std; list perm; vector result; int n, k; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i = 1; i
[BOJ] 5397: 키로거
2022. 9. 28. 01:15
알고리즘
문제: https://www.acmicpc.net/problem/5397 #include #include #include using namespace std; string input; int n; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i > input; list l; list::iterator t = l.end(); for (char c : input) { switch (c) { case '': if (t == l.end()) continue; t++; break; case '-': if (t == l.begin()) continue; if (t == l.end()) { l.e..
[BOJ] 1406: 에디터
2022. 9. 28. 00:59
알고리즘
문제: https://www.acmicpc.net/problem/1406 #include #include #include using namespace std; list l; list::iterator t; string s; int n; char cmd; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> s; for (char c : s) l.push_back(c); t = l.end(); cin >> n; cin.ignore(); for (int i = 0; i > cmd; switch (cmd) { case 'L': if (t != l.begin()) t--; break; case 'D': if (t != l.end())..
[BOJ] 10808: 알파벳 개수
2022. 9. 23. 13:42
알고리즘
문제: https://www.acmicpc.net/problem/10808 #include #include using namespace std; int main() { int alpha[26] = {}; string str; cin >> str; for (char c : str) alpha[c - 'a']++; for (int value : alpha) cout
[BOJ] 3273: 두 수의 합
2022. 9. 22. 17:57
알고리즘
문제: https://www.acmicpc.net/problem/3273 : 처음 제출한 코드 #include #include using namespace std; int main() { int n, x, result = 0; int arr[100000]; cin >> n; for (int i = 0; i > arr[i]; cin >> x; for (int i = 0; i > a[i]; check[a[i]]++; } cin >> x; for (int i = ..
[BOJ] 1475: 방 번호
2022. 9. 22. 14:09
알고리즘
문제: https://www.acmicpc.net/problem/1475 #include #include #include using namespace std; int main() { int digit[10] = {}; int max = 0; string str; cin >> str; for (char c : str) digit[c - '0']++; for (int i = 0; i < 9; i++) { if (i == 6) continue; (max < digit[i]) && (max = digit[i]); } double sixnine = ceil((double)(digit[6] + digit[9]) / 2); (max < sixnine) && (max = sixnine); cout
[BOJ] 2577: 숫자의 개수
2022. 9. 22. 13:13
알고리즘
문제: https://www.acmicpc.net/problem/2577 #include using namespace std; int main() { int check[10] = { 0, }; int a, b, c; int result; cin >> a >> b >> c; result = a * b * c; do check[result % 10]++; while (result /= 10); for (int i = 0; i < 10; i++) cout
[BOJ] 2562: 최댓값
2022. 9. 21. 23:37
알고리즘
문제: https://www.acmicpc.net/problem/2562 #include using namespace std; int main() { int n, order; int max = 0; for (int i = 0; i > n; if (max < n) { max = n; order = i + 1; } } cout
[BOJ] 2309: 일곱 난쟁이
2022. 9. 21. 23:25
알고리즘
문제: https://www.acmicpc.net/problem/2309 #include #include using namespace std; int main() { int total = 0; int n[9]; for (int i = 0; i > n[i]; total += n[i]; } sort(n, n + 9); int sub = total - 100; for (int i = 0; i < 9; i++) { for (int j = i + 1; j < 9; j++) if (n[i] + n[j] == sub) { for (int k = 0; k < 9; k++) { if (k == i || k == j) continue; cout