전체 글(331)
-
[BOJ] 11057번 : 오르막 수
1. problem : https://www.acmicpc.net/problem/11057 2. solution 1 :#include using namespace std;int n; int d[1003][10];int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x10/solutions/11057.cpp basic-algo-lecture/0x10/solutions/11057.cpp at master · encrypted-def/basic-algo-lecture바..
2024.09.29 -
[BOJ] 9465번 : 스티커
1. problem : https://www.acmicpc.net/problem/9465 2. solution 1 : #include using namespace std;const int val = 100005;int a[3][val];int main(void) { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n; int d[2][3][2] = { 0 }; cin >> n; for (int i = 1; i > a[i][j]; } for (int i = 1; i dp를 이용해 풀었다. 따라서, 세 가지 스텝을 따른다. 1. 테이블을 정의한다. d [i][j][k] --> i번째 열, j번째 행을 k== ..
2024.09.27 -
[BOJ] 4796번 : 캠핑
1. problem : https://www.acmicpc.net/problem/4796 2. solution 1 :#include using namespace std;int main(void) { ios::sync_with_stdio(0); cin.tie(0); int i = 0; while (true) { i++; long long l, p, v; cin >> l >> p >> v; if (l == 0 && p == 0 && v == 0) return 0; long long ans = 0; long long div = v / p; ans += div * l; if (v - div * p > l) ans += l; else ans += v - div * p; cout p를 이용해 몫을..
2024.09.26 -
[BOJ] 15894번 : 수학은 체육과목 입니다
1. problem : https://www.acmicpc.net/problem/15894 2. solution 1 :#include using namespace std;long long n;int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; cout 옆면을 옆으로 밀어버리고, 밑면은 밑으로 밀어버리고, 윗면은 위로 밀어버리면, 정사각형이라고 생각할 수 있다. 설명참조 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x12/solutions/15894.cpp basic-algo-lecture/0x12/solutions/15894.cpp at master · encryp..
2024.09.26 -
[BOJ] 11052번 : 카드 구매하기
1. problem : https://www.acmicpc.net/problem/11052 2. solution 1 :#include using namespace std;int t; int a[1005]; int d[1005]; // i일때 최댓값 int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> t; for (int i = 1; i > a[i]; d[0] = 0; for (int i = 1; i dp를 이용해 풀었다. 따라서 세 가지 스텝을 따른다. 1. 테이블을 정의한다. d[i] = i개를 살 때, 최대 금액이다. 2. 점화식을 작성한다. d[i] = max(d [i] , d [i-j] + a [j])) 3. 초기값을 설정한다. d[0]..
2024.09.26 -
[BOJ] 2302번 : 극장 좌석
1. problem : https://www.acmicpc.net/problem/2302 2. solution 1 :#include using namespace std;int d[42]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); d[0] = 1, d[1] = 1, d[2] = 2; for (int i = 3; i > n; cin >> m; int ans = 1; int start_idx = 1; while (m--) { int x; cin >> x; ans *= d[x - start_idx]; start_idx = x + 1; } ans *= d[n - start_idx + 1]; cout dp를 이용해 풀었다. 따라서, 세 가지 스텝..
2024.09.25