Beakjoon&프로그래머스/파이썬

[백준/파이썬] 24638번 Anno Domini 2022

현장 2025. 6. 14. 14:59

-Code

first = list(input().split())
second = list(input().split())

if "BC" in first:
    first_year = int(first[0])
    if "BC" in second:
        second_year = int(second[0])
        res = abs(first_year - second_year)
    else:
        second_year = int(second[1])
        res = first_year + second_year - 1
else:
    first_year = int(first[1])
    if "BC" in second:
        second_year = int(second[0])
        res = first_year + second_year - 1
    else:
        second_year = int(second[1])
        res = abs(first_year - second_year)
print(res)