Algorithm 136

C++ 알고리즘 - 백준 1932 정수 삼각형

https://www.acmicpc.net/problem/1932 #include #define endl "\n"using namespace std;/******** 전역변수 ********//******** 함 수 ********/int main(void) { /******** C++ INIT ********/ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /******** 지역변수 ********/ int input1; int input2; int pos; int idx; vector v; /******** 구 현 ********/ cin >> input1; // 점화식 : 2층 까지 수 벡터에 미리 삽입 (각 위치에 가능한 최대..

Algorithm/백준 2025.01.24
C++ 알고리즘 - 백준 1149 RGB 거리

https://www.acmicpc.net/problem/1149 #include #define endl "\n"using namespace std;/******** 전역변수 ********//******** 함 수 ********/int main(void) { /******** C++ INIT ********/ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /******** 지역변수 ********/ int input1; int input2; vector result; /******** 구 현 ********/ cin >> input1; // 점화식 : 첫 RGB 금액대 벡터에 삽입 cin >> input2; result.push_..

Algorithm/백준 2025.01.24
C++ 알고리즘 - 백준 18115 카드 놓기

https://www.acmicpc.net/problem/18115 #include #define endl "\n"using namespace std;/******** 전역변수 ********//******** 함 수 ********/int main(void) { /******** C++ INIT ********/ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /******** 지역변수 ********/ int input1; int input2; int num; deque card; stack select; /******** 구 현 ********/ cin >> input1; // 카드를 뽑을 순서를 스택에 추가 for (int i ..

Algorithm/백준 2025.01.24
C++ 알고리즘 - 백준 11053 가장 긴 증가하는 부분 수열

https://www.acmicpc.net/problem/11053 #include #define endl "\n"using namespace std;/******** 전역변수 ********//******** 함 수 ********/int main(void) { /******** C++ INIT ********/ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /******** 지역변수 ********/ int input1; int input2; int cnt; vector v; vector v2; /******** 구 현 ********/ cin >> input1; for (int i = 0; i > input2; v.push_b..

Algorithm/백준 2025.01.23
C++ 알고리즘 - 백준 1921 연속합 (다이나믹 프로그래밍)

https://www.acmicpc.net/problem/1912 #include #define endl "\n"using namespace std;/******** 전역변수 ********//******** 함 수 ********/int main(void) { /******** C++ INIT ********/ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /******** 지역변수 ********/ int input1; int input2; int sum = 0; vector v; /******** 구 현 ********/ cin >> input1; for (int i = 0; i > input2; // 입력된 수가 양수면 합산..

Algorithm/백준 2025.01.22
C++ 알고리즘 - 백준 1904 01타일

https://www.acmicpc.net/problem/1904 #include #define endl "\n"using namespace std;/******** 전역변수 ********/long long fibo[1000002] = { 0, 1, 1, };/******** 함 수 ********/int main(void) { /******** C++ INIT ********/ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); /******** 지역변수 ********/ int input; /******** 구 현 ********/ cin >> input; // 해당 문제는 피보나치 수열 문제이기 때문에 수열 생성 for (int i..

Algorithm/백준 2025.01.22
C++ 알고리즘 - 백준 9184 신나는 함수 실행 (동적 계획법 / 재귀)

https://www.acmicpc.net/problem/9184 #include #define endl "\n"using namespace std;/******** 전역변수 ********/int arr[21][21][21];/******** 함 수 ********/int w(int a, int b, int c) { if (a 20 || b > 20 || c > 20) return w(20, 20, 20); // 저장된 값은 재귀 호출 및 계산하지 않고 바로 리턴 else if (arr[a][b][c] != 0) return arr[a][b][c]; // 리턴하지 않고 값 저장 else if (a > input1 >> input2 >> input3; if (input1 == -1 && inpu..

Algorithm/백준 2025.01.22
C++ 알고리즘 - 백준 24416 알고리즘 수업 - 피보나치 수 1

https://www.acmicpc.net/problem/24416 #include #define endl "\n"using namespace std;/******** 전역변수 ********/int fibo[50] = { 0, 1, 1, };int cnt1 = 0, cnt2 = 0;/******** 함 수 ********/int fibonacci(int n) { if (n == 1 || n == 2) { cnt1++; return 1; } else return fibonacci(n - 1) + fibonacci(n - 2);}int main(void) { /******** C++ INIT ********/ ios::sync_with_stdio(false); cin.tie(NULL); cout...

Algorithm/백준 2025.01.21