문제 링크 9924번: The Euclidean Algorithm The famous Euclidean algorithm is found in Book VII of the Elements. The Elements was written in 300 B.C.~by the Greek mathematician Euclid. It is rumored that King Ptolemy, having looked through the Elements, hopefully asked Euclid if there were not a sho www.acmicpc.net 문제 풀이 A, B가 주어졌을 때, 특정한 계산을 통해 B가 0이 될 때 까지의 반복문 수행 횟수를 구해준다. 정답 코드 def solve(A, B, n) :..
문제 링크 8678번: Zbiór Pierwszy wiersz standardowego wejścia zawiera jedną liczbę całkowitą z (1 ≤ z ≤ 106), oznaczającą liczbę zestawów danych. W n kolejnych wierszach znajdują się opisy kolejnych zestawów. Każdy wiersz zawiera dwie liczby całkowite a, b (1 www.acmicpc.net 문제 풀이 두 입력값 a, b를 입력받을 때, b에서 a를 나눠주었을 때, 나머지가 0일 경우 "TAK"을 출력하고, 아닐 경우 "NIE"를 출력한다. 정답 코드 import sys input = sys.stdin.readlin..
문제 링크 8658번: Liczba Mamy daną liczbę całkowitą n, dla której chcemy znaleźć dwie wartości: najmniejszą oraz największą liczbę całkowitą, z przedziału od 1 do n, które nie są dzielnikami liczby n. www.acmicpc.net 문제 풀이 입력값 n이 주어졌을 때, 자연수 중 n의 약수가 아닌 가장 작은 수와 n보다 작은 수 중 n의 약수가 아닌 가장 큰 수를 차례로 출력해준다. 정답 코드 n = int(input()) i = 1 while n % i == 0 : i += 1 print(i, end = " ") i = n while n % i == 0 : ..
문제 링크 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 문제 풀이 주어진 입력값을 조건에 따라 출력해준다. 먼저, 입력값으로 자기 자신을 제외한 약수의 리스트를 구해준다. 약수 리스트의 합이 입력값보다 작으면..
문제 링크 6030번: Scavenger Hunt Farmer John has scattered treats for Bessie at special places in the pasture. Since everyone knows that smart cows make tasty milk, FJ has placed the treats at locations that require Bessie to think. He has given her two numbers, P and Q (1