728x90
6845번: Federal Voting Age
The input will consist of a number n (1 ≤ n ≤ 100) on a single line, indicating the number of birthdays to evaluate. Then, each of the following n lines, will be of the form y m d, where y is the year of a potential voter’s birth (0 ≤ y ≤ 2007),
www.acmicpc.net
문제 풀이
2007년 2월 27일 선거에 선거할 수 있는 나이일 경우 Yes를 출력하고, 아닐 경우 No를 출력해준다.
예제 입력 예시를 보면, 1989년 2월 28일 생은 No이지만, 1989년 2월 27일 생은 Yes이므로 이것을 기준으로 분기를 나눠주었다.
정답 코드
for _ in range(int(input())) :
y, m, d = map(int, input().split())
if y < 1989 : print("Yes")
elif y == 1989 and m < 2 : print("Yes")
elif y == 1989 and m == 2 and d < 28 : print("Yes")
else : print("No")
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 6903 - Trident [python] (0) | 2023.03.19 |
---|---|
[BOJ/백준] 6889 - Smile with Similes [python] (1) | 2023.03.19 |
[BOJ/백준] 6830 - It’s Cold Here! [python] (0) | 2023.03.19 |
[BOJ/백준] 6812 - Good times [python] (0) | 2023.03.19 |
[BOJ/백준] 6794 - What is n, Daddy? [python] (0) | 2023.03.19 |