Algorithm/PS

Algorithm/PS

[BOJ/백준] 6841 - I Speak TXTMSG [C++/python]

문제 링크 6841번: I Speak TXTMSG The program will output text immediately after each line of input. If the input is one of the phrases in the translation table, the output will be the translation; if the input does not appear in the table, the output will be the original word. The transla www.acmicpc.net 문제 풀이 미리 설정해놓은 단축 메세지가 있다면, 변환된 메세지로 출력해주는 문제이다. 파이썬은 두개의 리스트를 설정해서 문제를 해결했고, C++은 map을 통해 미리 단축 ..

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/백준] 6825 - Body Mass Index [C++/python]

문제 링크 6825번: Body Mass Index The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult’s health. The doctor measures the patient’s height (in metres) and weight (in kilograms), then calculates the BMI using the formula BMI = weight/(height × height). www.acmicpc.net 문제 풀이 문제에 제시된 BMI 공식에 맞춰 조건에 따라 출력해주면 된다. 정답 코드 C++ #include #include #include #include #include usin..

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..

Algorithm/PS

[BOJ/백준] 5341 - Pyramids [C++/python]

문제 번호 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..

Algorithm/PS

[BOJ/백준] 5300 - Fill the Rowboats! [C++/python]

문제 번호 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..

chanwoong1
'Algorithm/PS' 카테고리의 글 목록 (16 Page)