본문 바로가기

Algorithm/Implementation

(751)
(C++) - 백준(BOJ) 4632 : Copier Reduction https://www.acmicpc.net/problem/4623 4623번: Copier Reduction The input consists of one or more test cases, each of which is a single line containing four positive integers A, B, C, and D, separated by a space, representing an AxBmm image and a CxDmm piece of paper. All inputs will be less than one thousand. Followin www.acmicpc.net 자료형을 이용하는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 while loop를 수행합니다. 1. 줄여야할 이..
(C++) - 백준(BOJ) 6810 : ISBN https://www.acmicpc.net/problem/6810 6810번: ISBN The International Standard Book Number (ISBN) is a 13-digit code for identifying books. These numbers have a special property for detecting whether the number was written correctly. The 1-3-sum of a 13-digit number is calculated by multiplying the digits a www.acmicpc.net 간단한 입출력 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 마지막 세 수 a, b, c를 선언하고 입력해줍니다. 📔 정답출력 1-3 s..
(C++) - 백준(BOJ) 6812 : Good times https://www.acmicpc.net/problem/6812 6812번: Good times A mobile cell service provider in Ottawa broadcasts an automated time standard to its mobile users that reflects the local time at the user’s actual location in Canada. This ensures that text messages have a valid local time attached to them. For example www.acmicpc.net 간단한 계산, 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 시간 t를 선언 후 t를 입력해줍니다. 📔 풀이과정 세 가지 경..
(C++) - 백준(BOJ) 4619 : 루트 https://www.acmicpc.net/problem/4619 4619번: 루트 입력은 여러 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, B와 N이 주어진다. (1 ≤ B ≤ 1,000,000, 1 ≤ N ≤ 9) 입력의 마지막 줄에는 0이 2개 주어진다. www.acmicpc.net 구현 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 while loop를 수행하며 b, n을 선언 후 입력해줍니다. 둘 다 0이면 loop를 탈출합니다. 📔 풀이과정 a ^ n > b >> n; if(!b && !n) break; int minDiff = 0x3f3f3f3f; int minVal = 0x3f3f3f3f; for(int a = 1; pow(a,n)
(C++) - 백준(BOJ) 4562 : No Brainer https://www.acmicpc.net/problem/4562 4562번: No Brainer For each data set, there will be exactly one line of output. This line will be "MMM BRAINS" if the number of brains the zombie eats is greater than or equal to the number of brains the zombie requires to stay alive. Otherwise, the line will be "NO BRAINS". www.acmicpc.net 표준 입출력, while문, if문을 사용해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. 뇌를 먹은 개수 a, 생존..
(C++) - 백준(BOJ) 4084 : Viva la Diferencia https://www.acmicpc.net/problem/4084 4084번: Viva la Diferencia 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, a, b, c, d가 순서대로 주어진다. 입력의 마지막 줄에는 0이 4개 주어진다. (1 ≤ a,b,c,d ≤ 2,000,000,000) www.acmicpc.net 구현문제였습니다. 📕 풀이방법 📔 입력 및 초기화 while loop를 4개의 원소가 모두 0일 때까지 돕니다. 매 loop마다 vector num에 4개의 원소를 입력받습니다.몇 번째 수열인지 출력하기 위한 변수 cnt를 선언 후 0으로 초기화합니다. 📔 풀이과정 수렴하는지 검사하는 함수 isConvergence가 false인 동안 w..
(C++) - 백준(BOJ) 2997 : 네 번째 수 https://www.acmicpc.net/problem/2997 2997번: 네 번째 수 첫째 줄에 상근이가 고른 4개의 수 중 3개가 주어진다. 이 수는 크기 순이 아닐 수도 있고, -100보다 크거나 같고, 100보다 작거나 같은 정수이다. www.acmicpc.net 등차수열의 특성을 이용하는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 1. 3수를 입력받을 일차원 배열 a, 첫 번쨰 원소와 두 번쨰 원소의 차이 d, 두 번째와 세 번째 원소의 차이 d2를 선언 후 세 수를 입력해줍니다. 2. a배열의 원소를 오름차순으로 정렬해줍니다. 3. d = a[1] - a[0], d2 = a[2] - a[1]로 저장해줍니다. 📔 풀이과정 세 경우로 답이 나눠집니다. 1. d > d2인 경우 2 6 8같은..
(C++) - 백준(BOJ) 2975 : Transactions https://www.acmicpc.net/problem/2975 2975번: Transactions Input consists of a number of lines, each representing a transaction. Each transaction consists of an integer representing the starting balance (between –200 and +10,000), the letter W or the letter D (Withdrawal or Deposit), followed by a second integer www.acmicpc.net 표준입출력과 while, if문을 사용해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 while loop를 수행하며 다음..