분류 전체보기 203

프로그래머스 - 최대공약수와 최소공배수 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12940 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include #include using namespace std;vector solution(int n, int m) { vector answer; int a = (n>m)? m : n; for(int i=a; i>=1;i--) { if(n%i==0 && m%i==0) { answer.push_back(i); brea..

프로그래머스 - 최소 직사각형 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/86491?language=cpp 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  #include #include using namespace std;int solution(vector> sizes) { int answer = 0; int w=1001,h=1001; for(int i=0;i 최소직사각형 문제는 모든 명함을 수납할 수 있는 가장 작은 수납함의 크기를 계산하는 문제이다.명함은 회전시켜서 수납할 수 있다. 2차원 벡터로 각 명함의..

프로그래머스 - 예산 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12982 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 설명주어진 예산을 최대한 많은 부서에게 지원한다면 몇개의 부서에 지원가능한지를 묻는 문제이다.여기서 조건은 예산지원을 신청한 부서에게는 그 만큼의 예산을 반드시 줘야하기 때문에 그보다 모자라면 지원이 불가하다.따라서 지원금액이 낮은 부서부터 순서대로 지원하면 된다. #include #include #include #include #include using namespace std;int solutio..

Git 협업을 위한 Branch 정리

git 을 사용해 팀 프로젝트를 진행하는데 main 브랜치로 바로 작업 후 커밋 푸시를 하게 되면 내가 실수했을 때 모든 팀원에게 영향이 간다. 그래서 branch라는 것을 발견했고 알아보았다. 나뭇가지라는 의미로 워크트리에서 잔가지를 친다고 생각하면 된다. 현재 커밋지점에서 분기를 만들어서 내가 따로 기능을 수정하거나 추가, 삭제를 진행한다. 그리고 모두가 공유하고 있는 main 브랜치에 병합할 수 있다. 따라서 중간 중간 저장하고 싶을 때 마음대로 커밋을 해도 다른 팀원에게 영향가지 않는다. https://git-school.github.io/visualizing-git/ Visualizing Git git-school.github.io 이 사이트에서 연습해볼 수 있다. 사용법 git branch t..

개발 지식 2024.02.27

프로그래머스 - 3진법 뒤집기 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/68935 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; int solution(int n) { int answer = 0; string a=""; while(n>0) { a+=(char)(n%3); n/=3; } answer=0; int pow=1; for(int i=a.length()-1;i>=0;i--) { answer += (int)a[i]*pow; pow*=3..

프로그래머스 - 크기가 작은 부분 문자열 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/147355#qna 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; int solution(string t, string p) { long long answer = 0; long long pi = stoll(p); for(int i=0;i

프로그래머스 - 삼총사 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/131705 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; int answer = 0; void recur(vector number, int cnt, int num, int index) { if (cnt!=3&&index >= number.size())return; if (cnt == 3) { //cout

프로그래머스 - K번째수 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/42748 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include #include using namespace std; vector solution(vector array, vector commands) { vector answer; for (int i = 0; i < commands.size(); i++) { vector a; for (int j = commands[i][0]-1; j < commands[i][1]; j++) {..

프로그래머스 - 약수의 개수와 덧셈 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/77884 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; int solution(int left, int right) { int answer = 0; for(int i=left;i

프로그래머스 - 시저 암호 - C++

https://school.programmers.co.kr/learn/courses/30/lessons/12926 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr #include #include using namespace std; string solution(string s, int n) { for(int i=0;i= 97) { al = (al - 97 + n) % 26; s[i] = 'a'+al; } else { al = (al - 65 + n) % 26; s[i] = 'A' + al; } } } return s; } 설명 이 문제는 문자열에 있는 알파..