본문 바로가기

Algorithm

(2139)
(C++) - 백준(BOJ) 21598 : SciComLove https://www.acmicpc.net/problem/21598 21598번: SciComLove 당신은 싸이컴을 향해 절을 하려고 합니다. 하지만, 당신이 싸이컴에 들어오고 싶어서 절을 한 번 할 수도 있고, 싸이컴을 매우 싫어해 절을 두 번 할 수도 있습니다. 당신이 절을 할 횟수가 주어 www.acmicpc.net for문을 사용해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 출력횟수 n을 선언 후 입력받습니다. 📔 정답출력 n만큼 "SciComLove"를 출력해줍니다. 📕 Code #include using namespace std; int n; int main(){ cin >> n; for(int i = 0; i < n; i++) cout
(C++) - 백준(BOJ) 21591 : Laptop Sticker https://www.acmicpc.net/problem/21591 21591번: Laptop Sticker The single line of input contains four integers $w_c$, $h_c$, $w_s$ and $h_s$ ($1 \le w_c, h_c, w_s, h_s \le 1,000$), where $w_c$ is the width of your new laptop computer, $h_c$ is the height of your new laptop computer, $w_s$ is the width of the laptop s www.acmicpc.net 눈치껏 때려맞히는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 새로산 노트북의 w, h와 스티커의 w, h를 선언 ..
(C++) - 백준(BOJ) 21354 : Äpplen och päron https://www.acmicpc.net/problem/21354 21354번: Äpplen och päron En rad med två heltal $A,P$ ($0 \le A,P \le 1000)$, antalet äpplen Axel har lyckats sälja, och antalet päron Petra har lyckats sälja. www.acmicpc.net if문을 써보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 판 사과의 개수 apple, 판 배의 개수 pear, axel의 매출 axel, petra의 매출 petra를 선언하고 apple, pear에 입력받습니다. 📔 풀이과정 사과 1개당 7, 배 1개당 13이므로 axel = apple * 7, petra = pear * ..
(C++) - 백준(BOJ) 21335 : Another Eruption https://www.acmicpc.net/problem/21335 21335번: Another Eruption A volcano has recently erupted in Geldingadalur, Iceland. Fortunately this eruption is relatively small, and---unlike the infamous Eyjafjallajökull eruption---is not expected to cause delayed international flights or global outrage. There is some concern www.acmicpc.net sqrt함수를 사용해보는 간단수학 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 원의 넓이 circularArea,..
(C++) - 백준(BOJ) 21185 : Some Sum https://www.acmicpc.net/problem/21185 21185번: Some Sum Output a single word. The word should be 'Even', 'Odd', or 'Either', according to the rules given earlier. www.acmicpc.net 정수론 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 등차가 1인 연속 정수 구간의 길이 n을 선언 후 입력받습니다. 📔 풀이과정 2가지 경우가 있습니다. 1. n이 홀수인 경우 : 연속 구간이 홀수라면 (짝수가 짝수개, 홀수가 홀수개), (짝수가 홀수개, 홀수가 짝수개) 두 경우이므로 누적합이 짝수 또는 홀수가 나오게 됩니다. 2. 짝수인 경우 : 어떤 구간을 선택해도 짝수가 짝수개, 홀수..
(C++) - 백준(BOJ) 20976 : 2 番目に大きい整数 (The Second Largest Integer) https://www.acmicpc.net/problem/20976 20976번: 2 番目に大きい整数 (The Second Largest Integer) 3 つの整数 A, B, C が与えられる.これらのうち 2 番目に大きい数を出力せよ. www.acmicpc.net 정렬 후 두 번째로 큰 수를 출력하는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 세 개의 정수를 입력받을 일차원 변수 a를 선언 후 입력해줍니다. 📔 풀이과정 sort함수를 사용해 a의 원소를 오름차순으로 정렬합니다. 📔 정답출력 a[1]를 출력합니다. 📕 Code #include using namespace std; int a[3]; int main(){ for(int i = 0; i > a[i]; sort(a, ..
(C++) - 백준(BOJ) 20673 : Covid-19 https://www.acmicpc.net/problem/20673 20673번: Covid-19 The input consists of two lines. The first line contains an integer p (0 ⩽ p ⩽ 1000), showing the average number of new cases per day in every one million population in Hana’s city over the past two weeks. The second line contains an integer q (0 ⩽ www.acmicpc.net 입출력, 함수, if문을 사용해 푼 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 2주간 확진자 수 newCases, 환자 수 newHosp..
(C++) - 백준(BOJ) 20839 : Betygsättning https://www.acmicpc.net/problem/20839 20839번: Betygsättning På första raden står tre heltal $1 \leq x \leq 30$, $1 \leq y \leq 30$ och $1 \leq z \leq 30$, antalet A-, C- och E-kriterier som finns. På den andra raden står tre heltal $0 \leq x' \leq x$, $0 \leq y' \leq y$ och $0 \leq z' \leq z$, antalet A-, C- o www.acmicpc.net 입출력, 함수, if문을 사용해 푼 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 a기준, c기준, e기준 점수, 각 기준을 ..