Python

Algorithm/PS

[BOJ/백준] 8371 - Dyslexia [python]

문제 링크 8371번: Dyslexia In the recent years children in Byteland have been hardly reading any books. This has a negative influence on the knowledge of orthography among Byteland residents. Teachers at schools do their best to change this situation. They organize many different te www.acmicpc.net 문제 풀이 길이가 같은 두 문자열이 주어졌을 때, 같은 위치의 문자가 다른 경우의 갯수를 출력해준다. 정답 코드 n = int(input()) s1 = input() s2 = input..

Algorithm/PS

[BOJ/백준] 7947 - Koncert [python]

문제 링크 7947번: Koncert Dla każdego zestawu danych wypisz trzy liczby całkowite r, g, b stanowiące opis trzech składowych koloru światła padającego na gwiazdę, będące uśrednieniem światła padającego z reflektorów. Podaj wynik uwzględniając zaokrąglenie matematyc www.acmicpc.net 문제 풀이 이 문제는 테스트 케이스마다 10개의 줄이 들어오는데, 각 줄마다 입력되는 세 값을 r, g, b라고 할 때, 10개의 r, g, b 값의 평균을 구해주는 문제이다. 단, 소숫점 첫째자리에서 반올림해준다. 여..

Algorithm/PS

[BOJ/백준] 7782 - Alien [python]

문제 링크 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..

Algorithm/PS

[BOJ/백준] 7581 - Cuboids [python]

문제 링크 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

Algorithm/PS

[BOJ/백준] 7523 - Gauß [python]

문제 링크 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()) +..

Algorithm/PS

[BOJ/백준] 7510 - 고급 수학 [python]

문제 링크 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 ..

Algorithm/PS

[BOJ/백준] 6975 - Deficient, Perfect, and Abundant [python]

문제 링크 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 문제 풀이 주어진 입력값을 조건에 따라 출력해준다. 먼저, 입력값으로 자기 자신을 제외한 약수의 리스트를 구해준다. 약수 리스트의 합이 입력값보다 작으면..

Algorithm/PS

[BOJ/백준] 6974 - Long Division [python]

문제 링크 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..

chanwoong1
'Python' 태그의 글 목록 (8 Page)