#include #include using namespace std; vector solution(int brown, int red) { vector answer; int i, red_garo, red_sero; for(i = 1;i = i){ red_garo = red/i; red_sero = i; if( (red_garo+2)*(red_sero+2) - red == brown ){ answer.push_back(red_garo+2); answer.push_back(red_sero+2); break; } } } return answer; } 해결 방식 가로가 세로와 같거나 더 크다는 것, 갈색 카펫은 한 줄만 있다는 것이 조건이다. 그 말은 즉 (레드의 세로길이 + 2 ) * ( 레드의 가로길이 +2 ..
#include #include #include using namespace std; int solution(int stock, vector dates, vector supplies, int k) { int answer = 0; int idx = 0; priority_queue flour; // k-1일까지 사용할 밀가루를 공급받지 못할 동안 while문 진행 while(stock < k){ // 현재 남아있는 밀가루 stock 이전에 공급받을 수 있다면 우선순위 큐에 넣는다. // idx += 1을 해줘서 공급받은 밀가루는 큐에 넣지 못하도록 한다. for(int i = idx; i
#include #include using namespace std; vector number; int targett, answer = 0; void dfs(int index, int res){ if(index == number.size()){ if(res == targett) { answer += 1; } } else{ dfs(index + 1, res + number[index]); dfs(index + 1, res - number[index]); } } int solution(vector numbers, int target) { targett = target; number = numbers; dfs(0, 0); return answer; } 비슷한 문제를 많이 풀어봐서 이건 괜찮았당. 이래서 많은 ..
#include #include #include using namespace std; int solution(vector clothes) { int answer = 1; map hash; // 의상의 종류를 기준으로 카운팅 // hash -> first : 의상 종류 second : 개수 for(int i =0;i second + 1); } // 아무것도 안입는 경우를 뺀다. return answer-1; } 의상을 입는 경우를 모두 나열하는게 아니라서 그냥 의상 종류에 따라 개수를 세면 된다. map을 사용하여 first에는 의상 종류 second에는 의상 개수 만약 상의 3개 하의 2개 겉옷 5개 얼굴 4개가 있다면 상의 3개 + 상의 안입는 경우 1 = 4 하의 2개 + 하의 안입는 경우 1 = 3..
#include #include #include #include using namespace std; vector value; vector check; vector primeArr; void dfs(int level, int res){ if(level == value.size()) { if(res == 0 || res == 1) return; primeArr.push_back(res); } else{ dfs(level+1, res); for(int i = 0; i < value.size(); i++){ if(check[i] == 0){ check[i] = 1; dfs(level+1, res*10 + value[i]); check[i] = 0; } } } } int solution(string number..
원래 코드 #include #include #include #include using namespace std; int solution(vector scoville, int K) { int answer = 0; priority_queue minSco (scoville.begin(), scoville.end()); int first, second; while(true){ // minSco 길이가 2 이상이고 K 넘음 if( minSco.size() > 1 && minSco.top() >= K) break; // minSco 길이가 1인데 K 넘음 // minSco 길이가 1인데 K 안넘음 -> 절대 넘을 수 없음 if(minSco.size() == 1){ if(-minSco.top() >= K) answe..
- Total
- Today
- Yesterday
- django clean
- pythonanywhere배포
- iOS UITableView 출력안됨
- Realtime Database
- iOS 화면 안나옴
- 테이블출력안됨
- 장고 게시판
- 장고 태그달기
- Django
- 데이터베이스 추천
- ModelForm Form 차이
- django tag
- UITableViewController Not Working
- 실시간 데이터베이스
- python 웹 배포
- pythonanywhere배포방법
- django 게시판
- django 태그
- iOS 데이터베이스
- django 로그인접근
- CellForRowAt Not Called
- iOS 검은 화면
- CellForRowAt 호출안됨
- Firebase 데이터베이스 추천
- 웹 배포
- 알파벳 카운팅
- django 개발일지
- 까만 화면
- cleaned_data
- django pythoneverywhere
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |