C++ 알고리즘 - 백준 1748 수 이어 쓰기 1 https://www.acmicpc.net/problem/1748 #include #define endl "\n"using namespace std;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}int main(void) { CPP_INIT(); int input; int sum = 0; cin >> input; if (input 알고리즘 2025.01.19
C++ 알고리즘 - 백준 1476 날짜 계산 https://www.acmicpc.net/problem/1476 #include #define endl "\n"using namespace std;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}int main(void) { CPP_INIT(); int E, S, M; int ans = -1; cin >> E >> S >> M; while (E != 1 || S != 1 || M != 1) { E--; S--; M--; if (E 알고리즘 2025.01.19
C++ 알고리즘 - 백준 2309 일곱 난쟁이 https://www.acmicpc.net/problem/2309 #include #define endl "\n"using namespace std;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}int main(void) { CPP_INIT(); int input; int total = 0; vector v; for (int i = 0; i > input; v.push_back(input); total += input; } sort(v.begin(), v.end()); for (int i = 0; i 알고리즘 2025.01.19
C++ 알고리즘 - 백준 6588 골드바흐의 추측 https://www.acmicpc.net/problem/6588 #include #define endl "\n"using namespace std;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}int main(void) { CPP_INIT(); vector prime(1000002); for (int i = 2; i > input; while (input) { int num1 = 2; int num2 = input; while (!prime[num2]) num2--; while (num1 + num2 != input) { if (num1 + num2 > input) { num2--; whi.. 알고리즘 2025.01.19
C++ 알고리즘 - 백준 17427 약수의 합 2 https://www.acmicpc.net/problem/17427 #include #define endl "\n"using namespace std;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}int main(void) { CPP_INIT(); int input; long long answer = 0; cin >> input; for (int i = 1; i input = 10 일때,1의 개수 = 10 (10/1)2의 개수 = 5 (10/2)3의 개수 = 3 (10/3)4의 개수 = 2 (10/4)... 개수 x 숫자 의 모든 합이 정답 알고리즘 2025.01.19
C++ 알고리즘 - 백준 4375 1 (모듈러 연산 원칙 관련) https://www.acmicpc.net/problem/4375 #include #define endl "\n"using namespace std;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}int main(void) { CPP_INIT(); int num; while (true) { cin >> num; if (cin.eof()) return 0; int chk = 1; int jari = 1; while (true) { if (chk % num == 0) { cout (A mod B) mod B == A mod B chk %= num; 을 해준 후 chk % num을 한번 더 하.. 알고리즘 2025.01.19
C++ 알고리즘 - 백준 24060 알고리즘 수업 - 병합 정렬 1 https://www.acmicpc.net/problem/24060 #include #define endl "\n"using namespace std;int arr[500002];int tmp[500002];int cnt = 0;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}void merge(int left, int right) { int mid = (left + right) / 2; int i = left; int j = mid + 1; int k = left; int temp; while (i mid) temp = j; else temp = i; while (k > input1 >> input2; cnt .. 알고리즘 2025.01.17
C++ 알고리즘 - 백준 25501 재귀의 귀재 (참조자 문자열) https://www.acmicpc.net/problem/25501 #include #define endl "\n"using namespace std;int cnt = 0;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}int recursion(string& s, int l, int r) { cnt++; if (l >= r) return 1; else if (s[l] != s[r]) return 0; else return recursion(s, l + 1, r - 1);}int isPalindrome(string& s) { return recursion(s, 0, s.size() - 1);}int main(void.. 알고리즘 2025.01.17
C++ 알고리즘 - 백준 10870 피보나치 수 5 https://www.acmicpc.net/problem/10870 #include #define endl "\n"using namespace std;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}int fibo(int n) { if (n == 0) return 0; else if (n == 1 || n == 2) return 1; else return fibo(n - 1) + fibo(n - 2);}int main(void) { CPP_INIT(); int input; cin >> input; cout 알고리즘 2025.01.17
C++ 알고리즘 - 백준 11729 하노이 탑 이동순서 (재귀함수) https://www.acmicpc.net/problem/11729 #include #define endl "\n"using namespace std;void CPP_INIT() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}void hanoi(int n, int from, int by, int to) { if (n == 1) { cout > input; cout 알고리즘 2025.01.17