문제 링크 10187번: Golden There are many special irrational numbers in nature. One is the “golden ratio” represented by the Greek letter phi, φ, which has a value of φ = (1 + √5) / 2 = 1.61803399..... Given 2 real numbers, determine whether their ratio is equal (or close to www.acmicpc.net 문제 풀이 주어진 황금비율과 1%의 오차 범위 내에 입력값이 해당된다면, "golden"을 출력하고, 아니라면 "not"을 출력한다. 정답 코드 gold = 1.61803399 dif = gold * ..
문제 링크 10185번: Focus There is no longer a STAAR test in physics—the pressure is off! You can just learn physics for the sheer fun of learning about the natural world (and to prepare for college)! To celebrate this fact, here’s a program on lenses. Lenses use refraction of www.acmicpc.net 문제 풀이 문제에 주어진 1/f = 1/p + 1/q를 통해 f를 구해주어야 한다. 이 식을 통해 f를 구해주면 f = pq / (p + q)이다. 정답 코드 for _ in range(int(in..
문제 링크 10180번: Ship Selection Input begins with a line with one integer T (1 ≤ T ≤ 50) denoting the number of test cases. Each test case begins with a line with two space-separated integers N and D, where N (1 ≤ N ≤ 100) denotes the number of ships in the docking bay and D (1 www.acmicpc.net 정답 코드 for _ in range(int(input())) : N, D = map(int, input().split()) cnt = 0 for _ in range(N) : V, F, C ..
문제 링크 10178번: 할로윈의 사탕 할로윈데이에 한신이네는 아부지가 사탕을 나눠주신다. 하지만 한신이의 형제들은 서로 사이가 좋지않아 서른이 넘어서도 사탕을 공정하게 나누어 주지 않으면 서로 싸움이 난다. 매년 할로윈 www.acmicpc.net 문제 풀이 주어진 규칙에 따라 답을 출력해준다. c와 v에 대한 몫과 나머지를 구해준다. 정답 코드 for _ in range(int(input())) : c, v = map(int, input().split()) print("You get {:d} piece(s) and your dad gets {:d} piece(s).".format(c // v, c % v))
문제 링크 9950번: Rectangles Input is a series of lines, each containing 3 integers, l, w, and a ( 0 ≤ l w ≤100, 0 ≤ a ≤ 10,000) representing the length, width and area of a rectangle in that order. The integers are separated by a single space. In each row, only one of the val www.acmicpc.net 문제 풀이 입력값에 0의 위치에 따른 빈칸의 값을 채워 출력해준다. 정답 코드 while True : a, b, c = map(int, input().split()) if a == b == c =..
문제 링크 9945번: Centroid of Point Masses Input will be sets of points. Each set will be specified by the number of points n in the set followed by n lines of three numbers representing xi, yi, and mi values for i = 1 to n. All these numbers will be integers from 1 to 5000. That is, n will be from www.acmicpc.net 문제 풀이 무게 중심을 구해주기 위해 xi * m의 합을 m의 합으로 나누어주었다. 정답 코드 cnt = 1 while True : N = int(input..
문제 링크 9907번: ID The National Identity Card number of the city state of Eropagnis, NICE, consists of seven digits and a letter appended behind. This letter is calculated from the digits using the Modulo Eleven method. The steps involved in the computation are as follows: www.acmicpc.net 문제 풀이 문제에 주어진대로 입력값의 각 자릿수마다 숫자를 곱해준 뒤, 그 합을 11로 나눈 나머지를 "JABCDEFHIZ"의 인덱스로 매핑한다. 정답 코드 id_map = "JABCDEFGHIZ" ..
문제 링크 9776번: Max Volume The first line of the input contains a positive integer n (1 ≤ n ≤ 100) which is the number of figures. The n following lines contain the description of each figure. In case of a cone, the line begins with letter C and followed by 2 values: r and h res www.acmicpc.net 문제 풀이 입력값은 구, 원기둥, 원뿔로 들어오게 되는데, 각각의 부피를 구해준 뒤, 가장 부피가 큰 값을 출력해준다. 정답 코드 pi = 3.14159 ans = [] for _ in r..