본문 바로가기

Algorithm/Implementation

(751)
(C++) - 백준(BOJ) 5692 : 팩토리얼 진법 https://www.acmicpc.net/problem/5692 5692번: 팩토리얼 진법 상근이는 보통 사람들이 사는 것과는 조금 다른 삶을 사는 사람이다. 상근이는 이런 사람들의 시선이 부담스럽기 때문에, 자신만의 숫자를 개발하기로 했다. 바로 그 이름은 팩토리얼 진법이다. www.acmicpc.net 구현문제였습니다. 📕 풀이방법 📔 입력 및 초기화 테스트 케이스의 수가 주어지지 않았기 때문에 최대한 빠르게 입출력을 위해 c library와의 동기화를 끊어줍니다.while loop를 수행하면서 입력받습니다. 📔 풀이과정 getFacNum함수 내부에는 getFac함수가 동작합니다. getFac은 팩토리얼 수를 구한 결과를 반환하는 함수며 이 값을 토대로 팩토리얼 진법의 수를 getFacNum함수에서..
(C++) - 백준(BOJ) 5607 : 問題 1 https://www.acmicpc.net/problem/5607 5607번: 問題 1 A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う. 最初に, 2 人は与えられた n 枚ずつのカードを, 裏向きにして横一列に並べる. その後, 2 人 www.acmicpc.net 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 게임 라운드 횟수 n, a의 점수 aScore, b의 점수 bScore를 선언 후 입력해줍니다.이후 n만큼 loop를 수행하며 각각 뒤집은 카드의 숫자를 의미하는 a, b를 선언 후 입력해줍니다. 📔 풀이과정 조건에 따라 aScore, bScore에 더해줍니다. 📔 정답출력 aScore, bScore를 출력해줍니다. 📕 Code #include using n..
(C++) - 백준(BOJ) 5235 : Even Sum More Than Odd Sum https://www.acmicpc.net/problem/5235 5235번: Even Sum More Than Odd Sum When new programs arrive in the grid world, they start by playing the simplest of games in the Disc Arena against other novice programs. One of those games is played in front of a large board as follows: a sequence of numbers appears on the board, and the www.acmicpc.net 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. 테스트 케이스 t를 선언 후 입력받습니다...
(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, 이..