백준

Algorithm/PS

[BOJ/백준] 13116 - 30번 [C++/python]

문제 링크 13116번: 30번 첫 번째 줄에 테스트 케이스의 수 T (1 ≤ T ≤ 50 000)가 주어진다. 이후 T개의 테스트 케이스가 주어진다. 각 테스트 케이스는 한 줄로 구성되어 있으며, 각 줄에는 두 개의 정수 A와 B (1 ≤ A, B ≤ 1 www.acmicpc.net 문제 풀이 이 문제는 두 수 a, b의 공통 부모 중 최댓값을 찾는 문제이다. 이 문제의 경우 최댓값을 다음과 같이 찾을 수 있었다. a, b를 각각 33, 79라고 한다면 두 수의 부모 배열은 각각의 수를 2로 나눠가면서 구할 수 있다. 33 : [16, 8, 4, 2, 1] 79 : [39, 19, 9, 4, 2, 1] 두 부모의 배열을 구했다면, 두 수의 공통된 최대 부모 값이 4임을 알 수 있다. 정답 코드 C++ ..

Algorithm/PS

[BOJ/백준] 7595 - Triangles [C++/python]

문제 링크 7595번: Triangles Each line of input contains a single positive integer, n, 1 n; if (n == 0) break; for (int i = 1; i < n + 1; i++) { for (int j = 0; j < i; j++) { cout

Algorithm/PS

[BOJ/백준] 6888 - Terms of Office [C++/python]

문제 링크 6888번: Terms of Office In CS City, a mathematical place to live, the mayor is elected every 4 years, the treasurer is appointed every 2 years, the chief programmer is elected every 3 years and the dog-catcher is replaced every 5 years. This year, Year $X$, the newly elected mayo www.acmicpc.net 문제 풀이 문제 중 "the mayor is elected every 4 years, the treasurer is appointed every 2 years, the ch..

Algorithm/PS

[BOJ/백준] 6887 - Squares [C++/python]

문제 링크 6887번: Squares Gigi likes to play with squares. She has a collection of equal-sized square tiles. Gigi wants to arrange some or all of her tiles on a table to form a solid square. What is the side length of the largest possible square that Gigi can build? For example, wh www.acmicpc.net 문제 풀이 입력값 n보다 낮은 넓이의 정사각형 중, 정사각형 한 변의 최대 길이를 구해야한다. 반복문을 통해 1^2

Algorithm/PS

[BOJ/백준] 6840 - Who is in the middle? [C++/python]

문제 링크 6840번: Who is in the middle? In the story Goldilocks and the Three Bears, each bear had a bowl of porridge to eat while sitting at his/her favourite chair. What the story didn’t tell us is that Goldilocks moved the bowls around on the table, so the bowls were not at the right seats www.acmicpc.net 문제 풀이 3개의 입력값을 리스트에 받아준 뒤, 정렬 후 중간 값을 출력해주면 된다. 정답 코드 C++ #include #include #include #include..

Algorithm/PS

[BOJ/백준] 5524 - 입실 관리 [C++/python]

문제 링크 5524번: 입실 관리 JOI회사에서는 방에 들어가기 위해 입실 기록을 입력할 때 알파벳으로 이름을 입력한다. 그런데, 컴퓨터에 오류가 나서 대문자 소문자가 섞여버려 입실 기록이 읽기 힘들어졌다. JOI회사의 입실 www.acmicpc.net 문제 풀이 입력값 중 대문자 알파벳을 소문자로 바꿔 출력하는 문제이다. C++의 경우, 대문자의 아스키코드 [65 ~ 90]사이인 경우, 32를 더해 소문자 아스키코드로 변환해주는 방식으로 출력해줬다. 정답 코드 C++ #include #include #include #include #include using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(0), cout.tie..

Algorithm/PS

[BOJ/백준] 5358 - Football Team [C++/python]

문제 링크 5358번: Football Team Print the same list of names with every ‘i’ replaced with an ‘e’, every ‘e’ replaced with an ‘i’, every ‘I’ replaced with an ‘E’, and every ‘E’ replaced with an ‘I’. www.acmicpc.net 문제 풀이 입력받은 문자들을 다음의 조건을 통해 변환해서 출력하는 문제이다. 'e'는 'i'로 변환된다. 'i'는 'e'로 변환된다. 'E'는 'I'로 변환된다. 'I'는 'E'로 변환된다. 정답 코드 C++ #include #include #include #include #include using namespace std; #defin..

Algorithm/PS

[BOJ/백준] 5357 - Dedupe [C++/python]

문제 링크 5357번: Dedupe Redundancy in this world is pointless. Let’s get rid of all redundancy. For example AAABB is redundant. Why not just use AB? Given a string, remove all consecutive letters that are the same. www.acmicpc.net 문제 풀이 이 문제는 이전 값과 다른 값이 들어올 경우, 바뀌는 값을 출력해주는 문제이다. 처음 문자부터 탐색해야하므로, 임의로 이전 값을 공백으로 저장해주었다. 정답 코드 C++ #include #include #include #include #include using namespace std; #def..

chanwoong1
'백준' 태그의 글 목록 (15 Page)