문제 링크 7782번: Alien Once upon a time after winning another competition at KBTU, Bakhytzhan, Askar and Artem walked throw the Old Square. When they found some interesting rectangle lines on the asphalt, they stopped and screamed out ”R tree”. They screamed so loud that all www.acmicpc.net 문제 풀이 두 번째 줄의 입력값을 받아, 그 다음 줄부터의 입력 중 두 번째 줄의 입력값이 포함된다면 "Yes", 아니라면 "No"를 출력한다. 정답 코드 n = int(input()) b1, b2..
문제 링크 7581번: Cuboids Input is a series of lines, each containing 4 integers, l, w, h and v representing the length, width height and volume of a cuboid in that order. The integers are separated by a single space. 0 < l, w, h
문제 링크 7523번: Gauß 각 테스트 케이스마다 "Scenario #i:"를 출력한 다음, n부터 m까지 모든 정수의 합을 출력한다. 각 테스트 케이스 사이에는 빈 줄을 하나 출력한다. www.acmicpc.net 문제 풀이 1부터 n까지 자연수의 합 공식인 n * (n + 1) // 2를 이용해준다. n, m이 10, 100이라면, 1부터 m 까지의 합은 5050이고, 1부터 n까지의 합은 1부터 10까지이므로 55이다. 그렇다면 10부터 100까지 수의 합은 5050 - 55 + 10이 된다. 이말인즉슨, 1부터 100까지의 합 - 1부터 9까지의 합 => 1부터 m까지의 합 - 1부터 n - 1까지의 합으로 생각할 수 있다. 정답 코드 for i in range(1, int(input()) +..
문제 링크 7510번: 고급 수학 준규는 집을 짓고 있다. 준규는 모든 벽 모양을 직각 삼각형으로 만들려고 한다. 적절히 나무를 잘라 삼각형을 만들었지만, 준규는 각도를 측정할 수 있는 도구를 가지고 있지 않다. 어쩔 수 없 www.acmicpc.net 문제 풀이 테스트 케이스마다 주어지는 3개의 값이 직각삼각형을 만들 수 있는지 여부에 따라 "yes" or "no"를 출력해주면 된다. 정답 코드 for i in range(1, int(input()) + 1) : print(f"Scenario #{i}:") lst = [*map(int, input().split())] if (max(lst) ** 2) == (sum(lst) - min(lst) - max(lst)) ** 2 + min(lst) ** 2 ..
문제 링크 6975번: Deficient, Perfect, and Abundant Write a program that repeatedly reads a positive integer, determines if the integer is deficient, perfect, or abundant, and outputs the number along with its classification. A positive integer, n, is said to be perfect if the sum of its proper diviso www.acmicpc.net 문제 풀이 주어진 입력값을 조건에 따라 출력해준다. 먼저, 입력값으로 자기 자신을 제외한 약수의 리스트를 구해준다. 약수 리스트의 합이 입력값보다 작으면..
문제 링크 6974번: Long Division In days of yore (circa 1965), mechanical calculators performed division by shifting and repeated subtraction. For example, to divide 987654321 by 3456789, the numbers would first be aligned by their leftmost digit (see (1) below), and the divisor subtracte www.acmicpc.net 문제 풀이 이 문제는 몫과 나머지를 구해서 출력하는 문제이다. 파이썬에서는 큰 수 연산을 지원하기 때문에 아주 간단하게 문제를 풀 수 있다. 정답 코드 for _ in rang..
문제 링크 6903번: Trident A trident is a fork with three tines (prongs). A simple picture of a trident can be made from asterisks and spaces: * * * * * * * * * ******* * * * * In this example, each tine is a vertical column of 3 asterisks. Each tine is separated by 2 spaces. The ha www.acmicpc.net 문제 풀이 삼지창을 출력하는 문제이다. "*"을 주어진 간격에 맞추어 찍어준다. 정답 링크 t = int(input()) s = int(input()) h = int(input()) fo..
문제 링크 6889번: Smile with Similes A simile is a combination of an adjective and noun that produces a phrase such as "Easy as pie" or "Cold as ice". Write a program to input $n$ adjectives $(1 \le n \le 5)$ and $m$ nouns $(1 \le m \le 5)$, and print out all possible similes. The first two l www.acmicpc.net 문제 풀이 이 문제는 입력값을 두 개의 리스트에 담아 각각의 조합을 출력해주는 문제이다. 정답 코드 n = int(input()) m = int(input()) lst..