본문 바로가기

전공공부214

(c++) 프로그래머스 "124 나라의 숫자" https://programmers.co.kr/learn/courses/30/lessons/12899# 코딩테스트 연습 - 124 나라의 숫자 programmers.co.kr #include #include #include using namespace std; string solution(int n) { string answer = ""; while (n > 3) { if (n % 3 == 0) { answer = "4" + answer; n -= 1; } else { answer = to_string(n % 3) + answer; } n /= 3; } if (n == 3) { answer = "4" + answer; } else { answer = to_string(n) + answer; } retur.. 2022. 1. 12.
(c++) 프로그래머스 멀쩡한 사각형 나의 풀이 #include using namespace std; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } long long solution(int w, int h) { long long answer = (long long)w*(long long)h; int min_n = gcd(max(w, h), min(w, h)); answer -= (w + h - min_n); return answer; } 2022. 1. 12.
(c++) 프로그래머스 단체사진 찍기 https://programmers.co.kr/learn/courses/30/lessons/1835 코딩테스트 연습 - 단체사진 찍기 단체사진 찍기 가을을 맞아 카카오프렌즈는 단체로 소풍을 떠났다. 즐거운 시간을 보내고 마지막에 단체사진을 찍기 위해 카메라 앞에 일렬로 나란히 섰다. 그런데 각자가 원하는 배치가 모두 programmers.co.kr 나의 풀이 #include #include #include #include #include using namespace std; bool check(int r_diff, int w_diff, char type) { if (type == '=') { return r_diff == w_diff; } else if (type == ' 2022. 1. 11.
(c++) 프로그래머스 "카카오 프렌즈 컬러링북" https://programmers.co.kr/learn/courses/30/lessons/1829 코딩테스트 연습 - 카카오프렌즈 컬러링북 6 4 [[1, 1, 1, 0], [1, 2, 2, 0], [1, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 3], [0, 0, 0, 3]] [4, 5] programmers.co.kr 나의 풀이 #include #include #include #include using namespace std; bool check[100][100] = { false }; vector pictures; int M, N; int xs[] = { 0,-1,0,1 }; int ys[] = { -1,0,1,0 }; int dfs(int num, int i, int k) .. 2022. 1. 11.