일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Sort
- DP
- 다이나믹프로그래밍
- 최소공배수
- int
- 백준
- 알고리즘
- map
- Set
- 그래프
- 유클리드호제법
- stoi
- 분할정복
- 우선순위큐
- 문자열
- 에라토스테네스의 체
- 프로그래머스
- 백트래킹
- 정렬
- 깊이우선탐색
- C++
- 티스토리챌린지
- 이분탐색
- BFS
- 오블완
- N과M
- 배열
- priority_queue
- DFS
- vector
- Today
- Total
목록전체 글 (220)
안녕 세상아,
https://school.programmers.co.kr/learn/courses/30/lessons/133499# 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krsubstr 사용해서 2글자,. 3글자 나눠서 확인한다. 연속된 두 글자는 옹알이할 수 없기 때문에 첫 글자 저장하고 substr 사용한 후 첫글자 비교해서 다를 때만 answer++ 해준다. 만약 조건이 맞지 않으면 check를 false로 바꿔준다. #include #include using namespace std;int solution(vector babbling) { int answer = 0; for (int i = 0; i
https://www.acmicpc.net/problem/1193주어진 n이 몇번째 대각선에 있는지 찾은 후 대각선에서 몇번째 있는지 찾으면 된다. 몇번째인지 찾은 후 짝수일 때와 홀수일 때 나눠서 생각한다. 짝수일 때는 분자의 숫자가 커지고, 분모의 숫자는 작아진다. 반대로 홀수일 때는 분자의 숫자는 작아지지만, 분모의 숫자는 커진다. 자세한 설명은 코드 참고!#include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int dia = 0; // 대각선 번호 int sum = 0; // 대각선 최대 번호 //n이 포함된 대각선 찾기 ..
https://www.acmicpc.net/problem/11650vector 를 사용해서 값 받은 후 정렬해서 출력하면 된다. #include #include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector> v; for (int i = 0; i > a >> b; v.push_back({ a,b }); } sort(v.begin(), v.end()); for (int i = 0; i
참조자란? - 변수의 메모리 주소 직접 참조- 호출한 쪽의 원래 변수에 직접 접근하고 수정 가능- 함수 내부에서 값 바뀌면 원래 변수도 변경사항 반영#include #include #include using namespace std;void change(int answer) { answer+=10; return;}int main() { int answer = 0; change(answer); cout 출력값0참조자를 사용하지 않을 때는 함수에서 값을 아무리 바꿔도 원래 변수의 값으로 출력된다. 하지만,#include #include #include using namespace std;void change(int& answer) { answer+=10; return;..
https://school.programmers.co.kr/learn/courses/30/lessons/43165 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.krdfs를 사용하는 문제이다. n개의 정수가 주어지고 각 정수는 +, - 배치에 따라 값이 달라진다. n개의 정수가 주어질 때 경우의 수는 2의 n승이다. 각 값이 +,-에 따라 달라지기 때문에 깊이 우선 탐색을 하면 값을 구할 수 있다. 계속 반복해야되기 때문에 재귀를 사용한다는 것을 안다면 dfs 사용하는 문제라는 것을 빠르게 알 수 있다. #include #include using namespace std;//dfsvoid dfs(vect..
https://www.acmicpc.net/problem/4673배열 만들어서 소거법해서 지우는 방법으로 풀면 된다. 자릿수 대로 나눠서 풀면 된다. out of bound가 되면 안되니까 10000이하일때만 값 바꾸게 한다. #include #include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int arr[10001] = { 0 }; for (int i = 1; i
https://www.acmicpc.net/problem/2941c, d, l, n, s, z 일 때 if절로 분기 나눠서 풀면 된다. 크로아티아 숫ㅈㅏ 만나면 i++로 넘어가고 모든 조건 끝에 무조건 cnt++해주면 쉽게 풀 수 있다. #include #include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string str; cin >> str; int cnt = 0; for (int i = 0; i
https://www.acmicpc.net/problem/2751 sort 사용하면 됨.출력할 때 시간초과 대비하여 '\n' 사용ㅎㅐ주면 됨#include #include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector v; for (int i = 0; i > x; v.push_back(x); } sort(v.begin(), v.end()); for (int i = 0; i
https://www.acmicpc.net/problem/1316 그룹 단어 구별하는 방법1. 일단 각 알파벳 별 배열로 만들고 false로 세팅하기2. 처음 나오는 알파벳은 일단 true로 바꾸기3. 앞뒤 문자 비교해서 같으면 넘어가기 (continue)4. 앞뒤 문자 다르고 해당 알파벳이 true라면 cnt++하기5. cnt는 그룹 단어가 아니기 때문에 n에서 cnt 빼줌 #include #include using namespace std;int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int cnt = 0; for (int i = 0; i > str; bool arr[26] = { fa..
https://school.programmers.co.kr/learn/courses/30/lessons/17677 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr1. 영문자로 된 글자 쌍 추출 함수 1-1) 소문자로 바꾸기2. 교집합 개수 구하기 (중복 허용)3. 65536 곱한 후 소수점 아래 버림#include #include #include #include using namespace std;// 문자열에서 문자 쌍 추출vector extracts_vector(string s) { vector pairs; for (int i = 0; i v1 = extracts_vector(str1..