본문 바로가기

Algorithm

(2139)
(C++) - 백준(BOJ) 23825: SASA 모형을 만들어보자 https://www.acmicpc.net/problem/23825 23825번: SASA 모형을 만들어보자 당신은 SASA 연못에서 알파벳 S 모양의 블록 $N$개와 알파벳 A 모양의 블록 $M$개를 건졌다. 태영이는 연못에서 건진 블록을 이용해 학교에 전시할 SASA 모형을 최대한 많이 만들려고 한다. SASA 모형 $ www.acmicpc.net 간단한 수식 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 S의 개수n, A의 개수m을 선언 후 입력해줍니다. 📔 풀이과정 2개의 쌍 개수를 각각 구해줍니다. n / 2, m / 2가 됩니다. 이 중 SASA모형의 개수는 두 수 중 작은 값이 됩니다. 📔 정답출력 min(n/2,m/2)를 출력해줍니다. 📕 Code #include using namespac..
(C++) - 백준(BOJ) 5220 : Error Detection https://www.acmicpc.net/problem/5220 5220번: Error Detection In the midst of a fierce battle, Tony Stark’s suit constantly communicates with JARVIS for technical data. This data as transmitted takes the form of 16-bit integer values. However, due to various atmospheric issues (such as those created by all of that www.acmicpc.net 이진법 변환, 함수를 구현해 푼 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 테스트 케이스 t를 선언 후 t만큼 하기 숫..
(C++) - 백준(BOJ) 5102 : Sarah's Toys https://www.acmicpc.net/problem/5102 5102번: Sarah's Toys Input will be a number of lines, with each line representing a night in Sarah’s house. Each line will have 2 whole numbers, separated by a space. The first number is how many stuffed toys she owns at the time. The second number is the number of toys left www.acmicpc.net 구현문제였습니다. 📕 풀이방법 📔 입력 및 초기화 while loop를 수행합니다.지역변수 a, b, diff를 선언합니다. ..
(C++) - 백준(BOJ) 5101 : Sequences https://www.acmicpc.net/problem/5101 5101번: Sequences 11 is the 5th term The sequence is –1, -4, -7, -10 (-1+ -3 = -4, -4 + –3 = -7, -7+ -3 = -10) -8 isn’t in the sequence. www.acmicpc.net 예외를 조심해서 구현해야 하는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 while loop를 수행하며 a, b, c, ans를 선언 후 적절히 입력해줍니다. 📔 풀이과정 등차수열은 다음과 같은 공식이 성립합니다.a(초항) + (n - 1) * b = c이를 풀어 정리하면n*b = c - a + b가 됩니다.이 항이 성립하려면 n은 정수여야 하므로 n = (c - a ..
(C++) - 백준(BOJ) 5074 : When Do We Finish? https://www.acmicpc.net/problem/5074 5074번: When Do We Finish? For each line of input, produce one line of output containing a single time, also in the format hh:mm, being the end time of the event as a legal 24 hour time. If this time is not on the same day as the start time, the time will be in the format hh:mm +n, www.acmicpc.net 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 이벤트 시작 시간 sh, 분 sm, 이벤트 소요시간 eh, 이..
(C++) - 백준(BOJ) 20867 : Rulltrappa https://www.acmicpc.net/problem/20867 20867번: Rulltrappa I exempel 1 är båda köer tomma, så Paulina kan omedelbart börja gå upp längs rulltrappan. Om hon står stilla i rulltrappan färdas hon med 1 trappsteg per sekund, så det tar $\frac{50}{1} = 50$ sekunder. Om hon istället går upp i rulltrappan fä www.acmicpc.net 번역이 어려웠던 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. 에스컬레이터 계단 개수m, 서서 갈 때 초당 지나치는 계단 개수s, 걸어..
(C++) - 백준(BOJ) 4922 : Walk Like an Egyptian https://www.acmicpc.net/problem/4922 4922번: Walk Like an Egyptian Walk Like an Egyptian is an old multi-player board game played by children of the Sahara nomad tribes. Back in the old days, children would collect stones, and number each one of them. A game with N players requires N2 stones. Each player chooses N stones. www.acmicpc.net 단순 구현문제였습니다. 📕 풀이방법 📔 입력 및 초기화 while loop를 수행합니다.n, 전체 일꾼 수..
(C++) - 백준(BOJ) 4892 : 숫자 맞추기 게임 https://www.acmicpc.net/problem/4892 4892번: 숫자 맞추기 게임 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, n0으로 이루어져 있다. (0 < n0 < 1,000,000) 입력의 마지막 줄에는 0이 하나 주어진다. www.acmicpc.net 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 test case 번호를 위한 변수 testNum, n0 ~ n4를 선언해줍니다. 이 후 while loop를 수행하며 n0에 처음 수를 입력해줍니다. 📔 풀이과정 1. evenString을 지역변수로 선언 후 "odd"로 초기화해줍니다. 2. 문제의 공식대로 n1 ~ n4를 구해줍니다. 도 중 n1이 짝수면 evenString에 "..