본문 바로가기

전체 글495

[BOJ] 11047번: 동전 0 (c++) https://www.acmicpc.net/problem/11047 11047번: 동전 0 첫째 줄에 N과 K가 주어진다. (1 ≤ N ≤ 10, 1 ≤ K ≤ 100,000,000) 둘째 줄부터 N개의 줄에 동전의 가치 Ai가 오름차순으로 주어진다. (1 ≤ Ai ≤ 1,000,000, A1 = 1, i ≥ 2인 경우에 Ai는 Ai-1의 배수) www.acmicpc.net K에서 뺄수 있는 가장 큰 액수의 동전을 최대로 뺀다. #include #include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // 입력 int N, K; cin >> N >> K; vector coins(N); f.. 2020. 6. 17.
[BOJ]14395번: 4연산 (c++) https://www.acmicpc.net/problem/14395 14395번: 4연산 첫째 줄에 정수 s를 t로 바꾸는 방법을 출력한다. s와 t가 같은 경우에는 0을, 바꿀 수 없는 경우에는 -1을 출력한다. 가능한 방법이 여러 가지라면, 사전 순으로 앞서는 것을 출력한다. 연산의 아 www.acmicpc.net 방법 1: 큐에 {다음 숫자, 이제까지의 연산자 문자열} 저장하기 #include #include #include using namespace std; const long long limit = 1000000000LL; long long calculate(long long n, char c) { long long res = -1; if (c == '*') { res = n * n; } el.. 2020. 6. 17.
[BOJ]10026번: 적록색약 (c++) https://www.acmicpc.net/problem/10026 10026번: 적록색약 문제 적록색약은 빨간색과 초록색의 차이를 거의 느끼지 못한다. 따라서, 적록색약인 사람이 보는 그림은 아닌 사람이 보는 그림과는 좀 다를 수 있다. 크기가 N×N인 그리드의 각 칸에 R(빨강), G( www.acmicpc.net BFS 2번 실행하기 #include #include #include using namespace std; const int MAX = 100; char map[MAX][MAX + 1]; bool visit[MAX][MAX]; int dr_x[] = {0, 1, 0, -1}; int dr_y[] = {1, 0, -1, 0}; int N; enum {NORMAL, WEAK}; struct p.. 2020. 6. 17.
[프로그래머스]동적계획법(Dynamic Programming) : 정수 삼각형 (level 3)(c++) https://programmers.co.kr/learn/courses/30/lessons/43105 코딩테스트 연습 - 정수 삼각형 [[7], [3, 8], [8, 1, 0], [2, 7, 4, 4], [4, 5, 2, 6, 5]] 30 programmers.co.kr #include #include #include using namespace std; const int MAX = 500; int D[MAX + 1][MAX + 1]; int solution(vector triangle) { int N = triangle.size(); /* 점화식 : D[i][j] = tri[i][j]로 올 수 있는 경로의 i - 1번째 최대값 + tri[i][j] */ for (int i = 1; i 2020. 6. 17.