Python

Algorithm/PS

[BOJ/백준] 6779 - Who Has Seen The Wind [python]

문제 링크 6779번: Who Has Seen The Wind The input is two non-negative integers: h, the humidity factor, followed by M, the maximum number of hours Margaret will wait for the weather balloon to return to ground. You can assume 0 ≤ h ≤ 100 and 0 < M < 240. www.acmicpc.net 문제 풀이 문제에 주어진 방정식을 가지고 계산된 A가 0 이하가 되는 경우의 최소 t값을 구하는 문제이다. 만약 M보다 t가 커진다면 "The balloon does not touch ground in the given time."이라는..

Algorithm/PS

[BOJ/백준] 6750 - Rotating letters [python]

문제 링크 6750번: Rotating letters An artist wants to construct a sign whose letters will rotate freely in the breeze. In order to do this, she must only use letters that are not changed by rotation of 180 degrees: I, O, S, H, Z, X, and N. Write a program that reads a word and determines wh www.acmicpc.net 문제 풀이 입력되는 문자열 중 I, O, S, H, Z, X, N이 아닌 문자가 포함되어있는 경우, NO를 출력하고 아니라면 YES를 출력한다. 정답 코드 for i in..

Algorithm/PS

[BOJ/백준] 6721 - Backward numbers [python]

문제 링크 6721번: Backward numbers Backward numbers are numbers written in ordinary Arabic numerals but the order of the digits is reversed. The first digit becomes the last, and vice versa. For example, the number 1245 becomes 5421. Note that all leading zeroes are omitted. This means that www.acmicpc.net 문제 풀이 주어진 두 입력값을 거꾸로 뒤집어서 합을 구해준 뒤, 그 합을 다시 뒤집어서 출력해주면 된다. 정답 코드 for _ in range(int(input())) :..

Algorithm/PS

[BOJ/백준] 6437 - Golf [python]

문제 링크 6437번: Golf Whoever wants to learn the game of golf has to cope with several oddities first (as with every other game that originates from Great Britain). One of them is the way to count the number of strokes a player needed to put his golf ball in a hole. There is a www.acmicpc.net 문제 풀이 단순한 조건문 문제이다. 정답 코드 case = 1 while True : a, b = map(int, input().split()) if a == b == 0 : break prin..

Algorithm/PS

[BOJ/백준] 6378 - 디지털 루트 [python]

문제 링크 6378번: 디지털 루트 양의 정수 N의 디지털 루트를 구하려면 N을 이루고 있는 모든 자리수를 더해야 한다. 이때, 더한 값이 한 자리 숫자라면, 그 수가 N의 디지털 루트가 된다. 두 자리 이상 숫자인 경우에는 다시 그 www.acmicpc.net 문제 풀이 이 문제는 입력값의 자릿수를 모두 더했을 때 10 이하가 될 때 까지 반복하고 출력하는 문제이다. 맨 처음 입력값을 N이라 할 때, answer = N, tmp = 0으로 값을 초기화 한 후, answer를 10을 나눈 나머지를 tmp에 더해주며 answer는 10으로 계속 나누어준다. 이 과정이 다 끝나면 tmp는 다시 answer가 되고, answer가 10 이상일 경우, 다시 반복을 수행하게 된다. 정답 코드 while True ..

Algorithm/PS

[BOJ/백준] 6322 - 직각 삼각형의 두 변 [python]

문제 링크 6322번: 직각 삼각형의 두 변 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, 직각 삼각형의 세 변의 길이 a, b, c가 주어진다. a, b, c중 하나는 -1이며, -1은 알 수 없는 변의 길이 www.acmicpc.net 문제 풀이 이 문제의 입력값은 a, b, c의 형식으로 들어오고, 한 변이 -1일 경우, 직각삼각형이 되는 수를 찾는 문제이다. 문제에서는 c가 항상 가장 긴 변으로 나온다. 따라서 a, b를 찾는 경우는 c^2 - b^2 = a^2 혹은 c^2 - a^2 = b^2의 형식이고, c를 찾는 방법은 a^2 + b^2 = c^2를 통해 찾아준다. 문제에서 불가능한 경우도 존재하는데, c가 가장 긴 변이 아닐 경우이다. c^2..

Algorithm/PS

[BOJ/백준] 6321 - IBM 빼기 1 [python]

문제 링크 6321번: IBM 빼기 1 첫째 줄에 컴퓨터의 개수 n이 주어진다. 다음 줄부터 n개의 줄에는 컴퓨터의 이름이 주어진다. 컴퓨터의 이름은 최대 50글자이며, 알파벳 대문자로만 이루어져 있다. www.acmicpc.net 문제 풀이 입력받은 문자열의 각 문자 알파벳을 다음 알파벳으로 변환하여 출력하는 문제이다. 'A'일 경우 'B'로 출력하고, 'Z'일 경우 'A'로 출력하면 된다. 'Z'일 경우에만 'A'를 출력하도록 했고, 나머지의 경우에는 아스키코드 값으로 변환하여 1을 더해준 후 다시 알파벳으로 변환해주었다. 정답 코드 for i in range(1, int(input()) + 1) : print(f"String #{i}") s = input() for i in s : if i == "..

Algorithm/PS

[BOJ/백준] 6249 - TV Reports [python]

문제 링크 6249번: TV Reports The first line of the input contains three positive integers n, p, and h (separated by a space), where n (1 ≤ n,p,h ≤ 10,000) specifies the number of days you are hired for to record the headlines, p is the price of Dollar one day before you start your www.acmicpc.net 문제 풀이 조건에 따라 입력값을 처리하는 문제이다. 바로 이전 가격보다 낮다면, NTV로 이전값과 현재값의 차이를 출력하고, 최댓값이 들어오면 BBTV로 최대값을 출력해준다. 정답 코드 n..

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