백준 12353번: Dr. Spaceman의 특별한 알고리즘 #Python

ColorlessDia·2025년 11월 20일

algorithm/baekjoon

목록 보기
732/836
import sys
from math import ceil, floor

def formatted_height(h):
    feet, inch = divmod(h, 12)

    return f'{feet}\'{inch}"'

input = sys.stdin.readline

T = int(input())

for t in range(1, T + 1):
    gender, mother_height, father_height = input().rstrip().split()
    mf, mi = map(int, mother_height[:-1].split("'"))
    ff, fi = map(int, father_height[:-1].split("'"))

    height = ((mf * 12) + mi) + ((ff * 12) + fi)
    
    if gender == 'B':
        height += 5
    else:
        height -= 5
    
    height /= 2
    min_height = formatted_height(ceil(height - 4))
    max_height = formatted_height(floor(height + 4))

    print(f'Case #{t}: {min_height} to {max_height}')

0개의 댓글