목록전체 글 (722)
N
https://school.programmers.co.kr/learn/courses/30/lessons/250137# 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 0초부터 시작해서 공격을 받는 시간까지 for문을 돌면서 할 수 있겠지만,덜 오래 걸리는 방식은 attacks만 순회하면 될 것 같다는 생각이 들었다. current_time = 공격을 받는 사이의 시간을 알아내기 위한 변수.current_health = 현재 체력.taken_time, recovery, additional = bandage에 해당하는 값(시전 시간, 초당 회복량, 추가 회복량) 1. attacks를 순회하면서 체력 회복과 데미지를 ..
https://school.programmers.co.kr/learn/courses/30/lessons/132267 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 문제만 잘 이해하면 풀 수 있는 문제.설명은 굳이 없어도 될 것 같다.int solution(int a, int b, int n) { int answer = 0; while (n >= a) { answer += ((n / a) * b); n = ((n / a) * b) + (n % a); } return answer;}
https://school.programmers.co.kr/learn/courses/30/lessons/131705 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 주어진 문제의 범위를 보면 3중 for문으로 풀 수 있지만,다른 방식으로 접근할 수 있다. 주어진 number를 순회하면서, 값을 더할지 말지 결정하면 된다.이를 결정하기 위해서는 vector를 선언하고, 이 vector는 {현재 num을 더한 결과, 더한 숫자의 개수}를 저장한다. 1. acc vector에는 아무것도 더하지 않은 값인 {0, 0}을 넣어준다.2. number를 순회3. 순회하면서 acc에 push_back을 해주기 때문에, 무한 루..
https://school.programmers.co.kr/learn/courses/30/lessons/131128 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr map을 이용한 문제 풀이. 주어진 두 string x,y를 순회해서 숫자가 몇개씩 존재하는지 x,y map에 각각 저장하는 방식으로 생각했다. 문제풀이)1. x,y string을 순회하면서 카운팅 할 xMap, yMap을 fillMap 함수를 통해서 각 맵에 카운팅을 한다.2. 맵을 모두 채웠으면 0~9까지의 수를 채울 수 있는 만큼 answer에 채우면 된다.xVal과 yVal은 각 맵에 저장되어 있는 숫자의 카운트를 뜻한다.즉, key = i(0..
https://school.programmers.co.kr/learn/courses/30/lessons/340213 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr #include #include #include using namespace std;vector splitTime(string time) { vector tokens; size_t pos = 0; string token; string delimiter = ":"; while ((pos = time.find(delimiter)) != string::npos) { token = time.substr(0, po..
https://school.programmers.co.kr/learn/courses/30/lessons/389478 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 복잡하게 공식을 찾아내는 것보다,brute force로 하는게 더 빠르다고 느낀 문제. 문제의 핵심은 순서대로 숫자를 늘릴지, 역순으로 숫자를 늘릴지인 것 같다. #include #include using namespace std;int getFloor(int n, int w) { return (n / w) + (n % w == 0 ? 0 : 1);}int solution(int n, int w, int num) { int answer = ..
https://school.programmers.co.kr/learn/courses/30/lessons/258712?language=cpp 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr #include #include #include #include #include using namespace std;int solution(vector friends, vector gifts) { int answer = 0; map> history; // giver : (taker, count) map> score; // name : (give, take) // initialize the histor..
https://school.programmers.co.kr/learn/courses/30/lessons/340203 프로그래머스SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr 주어진 cpr과 basic_order를 순회하면서 같은 값이면 해당 인덱스 값을 +1 해서 answer에 있는 값을 바꿔주는 문제.#include #include using namespace std;vector solution(vector cpr) { vector answer = {0, 0, 0, 0, 0}; vector basic_order = {"check", "call", "pressure", "respiration", "repeat"..