본문 바로가기 메뉴 바로가기

호로록

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

호로록

검색하기 폼
  • 분류 전체보기 (193)
    • MFC (0)
    • 알고리즘 (122)
      • C++ (93)
      • C (29)
    • 클라우드 (0)
    • django project (42)
      • 커뮤니티 (10)
      • 쇼핑몰 (11)
      • 블로그 (13)
      • 인스타그램 (7)
    • python (11)
    • 아무거나 (0)
    • git Error Handling (1)
    • 데이터 시각화 (12)
  • 방명록

분류 전체보기 (193)
[C++] 프로그래머스 카펫

#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 ..

알고리즘/C++ 2020. 3. 8. 13:17
[C++] 프로그래머스 라면공장

#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

알고리즘/C++ 2020. 3. 7. 16:10
[C++] 프로그래머스 타겟 넘버

#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; } 비슷한 문제를 많이 풀어봐서 이건 괜찮았당. 이래서 많은 ..

알고리즘/C++ 2020. 3. 7. 15:18
[C++] 프로그래머스 구명보트

#include #include #include using namespace std; int solution(vector people, int limit) { int answer = 0; sort(people.begin(), people.end()); int i = 0, j = people.size()-1; while(j > i){ if(people[i] + people[j]

알고리즘/C++ 2020. 3. 7. 14:55
[C++] 프로그래머스 위장

#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..

카테고리 없음 2020. 3. 7. 13:37
[C++] 프로그래머스 전화번호 목록

#include #include #include using namespace std; bool solution(vector phone_book) { bool answer = true; sort(phone_book.begin(), phone_book.end()); int i, j; for(i = phone_book.size()-1; i>=0; i--){ for(j = 0; j

알고리즘/C++ 2020. 3. 6. 18:53
[C++] 프로그래머스 소수 찾기

#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..

알고리즘/C++ 2020. 3. 6. 17:44
[C++] 프로그래머스 더 맵게

원래 코드 #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..

알고리즘/C++ 2020. 3. 6. 17:02
이전 1 2 3 4 5 6 7 8 ··· 25 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • 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
more
«   2025/07   »
일 월 화 수 목 금 토
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
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바