문제 링크 9298번: Ant Entrapment For each case output the line “Case x:” where x is the case number, on a single line, followed by the string “Area” and the area of the fence as a floating-point value and then a comma, followed by a space and then “Perimeter” and the perimeter www.acmicpc.net 문제 풀이 주어진 입력값 중 x의 최댓값과 x의 최솟값으로 x의 길이를 구하고, y의 최댓값과 y의 최솟값으로 y의 길이를 구해 사각형의 넓이와 둘레를 출력해준다. 정답 코드 import sys ..
문제 링크 9297번: Reducing Improper Fractions For each case output the line “Case x:” where x is the case number, on a single line, followed by a space, and then proper fraction. Each fraction will be of the form “I N/D”, where I is the integer part, N is the numerator of the fractional part, www.acmicpc.net 문제 풀이 이 문제는 두 수 n, m이 주어졌을 때, n을 m으로 나누었을 때의 몫, 나머지에 따라 출력이 달라져야한다. 정답 코드 for i in range(1, i..
문제 링크 9295번: 주사위 각 테스트 케이스마다 "Case x: "를 출력한 다음, 주사위를 두 번 던져 나온 두 수의 합을 출력한다. 테스트 케이스 번호(x)는 1부터 시작한다. www.acmicpc.net 문제 풀이 테스트케이스마다 주어지는 두 수의 합을 조건에 맞게 출력한다. 정답 코드 for i in range(1, int(input()) + 1) : n, m = map(int, input().split()) print(f"Case {i}: {n + m}")
문제 링크 9288번: More Dice For each case, output the line “Case x:” where x is the case number, on a single line. Then output a list of possible dice-pairs that result in that sum, one on each line. Each dice-pair should be comma-separated and enclosed by parentheses. In each pa www.acmicpc.net 문제 풀이 이 문제는 두 개의 주사위의 합으로 주어진 입력값을 표현할 수 있는 경우의 수를 구하는 문제이다. 두 주사위 중 처음으로 출력될 주사위는 두번째로 출력될 주사위보다 작아야하므로 그..
문제 링크 9161번: Sir Bedavere’s Bogus Division Solutions The wise Sir Bedavere often uses non-standard logic, yet achieves positive results. Well, it seems he has been at it again, this time with division. He has determined that canceling the common digit of a numerator and denominator produces the correct answe www.acmicpc.net 문제 풀이 두 세 자리의 수 x, y가 있을 때, x의 일의 자리 수와 y의 백의 자리 수가 같을 경우, 두 수를 제거해서 출력해..
문제 링크 9094번: 수학적 호기심 첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, n과 m이 주어진다. 두 수는 0보다 크고, 100보다 작거나 같다. www.acmicpc.net 문제 풀이 이 문제는 주어진 공식이 정수인 쌍의 갯수를 구하는 문제이다. 주어진 공식을 반복문을 통해 계속 계산하다보면, 계산에 대한 시간이 매우 커져 시간초과가 발생한다. 따라서, a^2+b^2의 값을 미리 계산해놓은 뒤, 테스트케이스가 들어올 때마다 미리 계산된 값에 m을 더해주는 방식으로 계산을 줄일 수 있다. 정답 코드 memory = [[0] * 101 for _ in range(101)] for b in range(2, 101) : for a in range(1, b..
문제 링크 9085번: 더하기 입력의 첫 줄에는 테스트 케이스의 개수 T(1 ≤ T ≤ 10)가 주어진다. 각 테스트 케이스는 첫 줄에 자연수의 개수 N(1 ≤ N ≤ 100)이 주어지고, 그 다음 줄에는 N개의 자연수가 주어진다. 각각의 자연 www.acmicpc.net 문제 풀이 테스트 케이스 별 주어지는 숫자열의 합을 출력해준다. 정답 코드 for _ in range(int(input())) : input() print(sum([*map(int, input().split())]))
문제 링크 9063번: 대지 첫째 줄에는 점의 개수 N (1 ≤ N ≤ 100,000) 이 주어진다. 이어지는 N 줄에는 각 점의 좌표가 두 개의 정수로 한 줄에 하나씩 주어진다. 각각의 좌표는 -10,000 이상 10,000 이하의 정수이다. www.acmicpc.net 문제 풀이 주어진 입력값들로 최대의 직사각형을 찾으려면 (max(x) - min(x)) * ((max(y) * min(y)) 의 값을 구하면 된다. 정답 코드 import sys input = sys.stdin.readline x_lst = [] y_lst = [] for _ in range(int(input())) : x, y = map(int, input().split()) x_lst.append(x) y_lst.append(y) ..