문제 링크 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..
문제 링크 6378번: 디지털 루트 양의 정수 N의 디지털 루트를 구하려면 N을 이루고 있는 모든 자리수를 더해야 한다. 이때, 더한 값이 한 자리 숫자라면, 그 수가 N의 디지털 루트가 된다. 두 자리 이상 숫자인 경우에는 다시 그 www.acmicpc.net 문제 풀이 이 문제는 입력값의 자릿수를 모두 더했을 때 10 이하가 될 때 까지 반복하고 출력하는 문제이다. 맨 처음 입력값을 N이라 할 때, answer = N, tmp = 0으로 값을 초기화 한 후, answer를 10을 나눈 나머지를 tmp에 더해주며 answer는 10으로 계속 나누어준다. 이 과정이 다 끝나면 tmp는 다시 answer가 되고, answer가 10 이상일 경우, 다시 반복을 수행하게 된다. 정답 코드 while True ..
문제 링크 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 == "..
문제 링크 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..
문제 링크 6190번: Another Cow Number Game The cows are playing a silly number game again. Bessie is tired of losing and wants you to help her cheat. In this game, a cow supplies a number N (1
문제 링크 6162번: Superlatives Typically, droughts are classified into “abnormally dry”, “moderate drought”, “severe drought”, “extreme drought”, and “exceptional drought”. The current drought is so “exceptional” in most of California that there have been discuss www.acmicpc.net 문제 풀이 두 입력값 A, E를 입력 받으면, 조건에 따라 출력해주는 문제이다. E보다 A가 5배 클때마다 "mega"를 더해서 출력해준다. 만약 25배가 클 경우, "mega mega"를 더해 출력해준다. 정답 코드 f..
문제 링크 5789번: 한다 안한다 첫째 줄에는 테스트 케이스의 개수 N이 주어진다. (1 ≤ N ≤ 1000) 각 테스트 케이스는 한 줄로 이루어져 있으며, 0과 1로 이루어진 문자열이 주어진다. 문자열의 길이는 항상 짝수이고, 1000보다 작 www.acmicpc.net 문제 풀이 문자열의 가장 가운데에 위치한 두 문자만 비교해주어도 된다. 두 문자가 같을 경우 "Do-it" 을 출력하고, 틀릴 경우 "Do-it-Not"을 출력한다. 정답 코드 for _ in range(int(input())) : s = input() if s[len(s) // 2 - 1] == s[len(s) // 2] : print("Do-it") else : print("Do-it-Not")
문제 링크 5753번: Pascal Library Pascal University, one of the oldest in the country, needs to renovate its Library Building, because after all these centuries the building started to show the effects of supporting the weight of the enormous amount of books it houses. To help in the renov www.acmicpc.net 문제 풀이 모든 케이스마다 참석한 사람이 한명이라도 존재할 때 "yes"를 출력하고, 아니라면 "no"를 출력해준다. 정답 코드 while True : lst = [*map(..