문제 링크 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..
문제 링크 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
문제 링크 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..
문제 링크 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..
문제 링크 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..
문제 링크 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..
문제 번호 5341번: Pyramids The input will be a sequence of integers, one per line. The end of input will be signaled by the integer 0, and does not represent the base of a pyramid. All integers, other than the last (zero), are positive. www.acmicpc.net 문제 풀이 입력값으로 n이 주어질 때, 1부터 n까지의 합을 출력하는 문제이다. 0이 입력되면 종료된다. 메모리 제한이 128MB로 4바이트의 크기를 가지는 int형은 128MB = 128 * 1024KB = 128 * 1024 * 1024B = int형 128 * 1..
문제 번호 5300번: Fill the Rowboats! The output will be the number of each pirate separated by spaces, with the word ”Go!” after every 6th pirate, and after the last pirate. www.acmicpc.net 문제 풀이 6의 배수일때 혹은 마지막 수 출력 이후 "Go!"를 출력하는 문제이다. 정답 코드 C++ #include #include #include #include #include using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0) #define ll long lon..