본문 바로가기
  • Let's study

C++54

[C++] 백준 22155: Простая задача 문제 https://www.acmicpc.net/problem/22155 22155번: Простая задача Первая строка содержит одно целое число n (1 ≤ n ≤ 121) — количество задач. Далее, в n строках задано по два целых числа i и f (0 ≤ i, f ≤ 10) www.acmicpc.net 해결방법 입력받은 i, f가 i i >> f; if ((i 2023. 5. 17.
[C++] 백준 27890: 특별한 작은 분수 문제 https://www.acmicpc.net/problem/27890 27890번: 특별한 작은 분수 첫 번째 줄에 $0$초에서의 분수의 높이 $x_0$와 $N$이 주어진다. $x_0$와 $N$은 모두 정수이다. www.acmicpc.net 해결방법 시간에 따라 낮아지는 분수의 높이를 구하는 문제이다. n-1초 때 분수의 높이가 바뀌는 계산을 하면 n초에서의 높이가 구해지기 때문에 0 ~ n-1초까지 계산을 한다. 분수의 높이(x)가 짝수면 ( x / 2 ) ^ 6으로, 홀수면 ( 2 * x ) ^ 6으로 분수의 높이를 바꿔주고 마지막으로 계산된 x를 출력한다. 코드 #include using namespace std; int main() { ios_base::sync_with_stdio(0); ci.. 2023. 5. 16.
[C++] 백준 5358: Football Team 문제 https://www.acmicpc.net/problem/5358 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 해결방법 while문 안에 getline(cin, str) 함수를 사용하여 입력값이 없을 때 까지 입력받고 문자열을 for문으로 하나씩 보면서 e는 i로, E는 I로, i는 e로, I는 E로 변경 후 출력한다. 코드 #include #include using namespace .. 2023. 5. 15.
[C++] 백준 6825: Body Mass Index 문제 https://www.acmicpc.net/problem/6825 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 해결방법 입력은 몸무게(w), 키(h) 순이며 w / (h * h)로 bmi를 구해 조건에 따라 출력한다. 코드 #inc.. 2023. 5. 14.
[C++] 백준 25784: Easy-to-Solve Expressions 문제 https://www.acmicpc.net/problem/25784 25784번: Easy-to-Solve Expressions When one looks at a set of numbers, one usually wonders if there is a relationship among them? This task is more manageable if there are only three numbers. Given three distinct positive integers, you are to determine how one can be computed using the othe www.acmicpc.net 해결방법 세 수를 배열에 넣어 정렬한 뒤, 첫번째 수와 두번째 수를 더하거나 곱한 게 세번.. 2023. 5. 13.
[C++] 백준 6887: Squares 문제 https://www.acmicpc.net/problem/6887 6887번: Squares Gigi likes to play with squares. She has a collection of equal-sized square tiles. Gigi wants to arrange some or all of her tiles on a table to form a solid square. What is the side length of the largest possible square that Gigi can build? For example, wh www.acmicpc.net 해결방법 입력받은 숫자를 sqrt 함수를 이용하여 제곱근을 구하고 앞에 (int)를 붙여 정수로 만들어 출력하면 된다. 코드 .. 2023. 5. 12.