[백준/파이썬] 10698번 풀이

업데이트:



문제 정보


풀이

문제

Ahmed Aly was the chief judge for the last Arab Collegiate Programming Contest, and he will be the chief judge for the next one also. He was an ACM ICPC world finalist in Oralndo 2011, and currently he is a software engineer at Google.

During the last ACPC contest, it was the first time that the chief judge didn’t not attend the contest, and this was because his son Omar was expected to be born a few days before or after the contest (he was born 10 days after the contest), so he could not travel to Jordan. …

입력 요약
Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100). …

출력 요약
For each test case print a single line containing “Case n:” (without the quotes) where n is the test case number (starting from 1) followed by a space then “YES” (without the quotes) if the equation is correct or “NO” (without the quotes) if the equation is wrong.

코드

for T in range(int(input())):
    a,b=input().split('=')
    c=eval(a+'=='+b)
    print(f'Case {T+1}: {"YES"if c else"NO"}')

설명

핵심은 구현 관점에서 Ahmed Aly was the chief judge for the last Arab Collegiate Programming Contest, and he will be the chief judge for the next one also. …를 만족하도록 로직을 구성하는 것입니다.

코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.

경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.



이런 주제는 어떠신가요?

비슷한 난이도와 유형의 문제를 이어서 보면 풀이 감각을 더 빠르게 잡기 좋습니다.

댓글남기기