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

업데이트:



문제 정보


풀이

문제

In the United States of America, telephone numbers within an area code consist of 7 digits: the prefix number is the first 3 digits and the line number is the last 4 digits. Traditionally, the 555 prefix number has been used to provide directory information and assistance as in the following examples:

  • 555-1212

  • 555-9876

  • 555-5000

  • 555-7777

Telephone company switching hardware would detect the 555 prefix and route the call to a directory information operator. …

입력 요약
The input consists of a single line containing a 7-digit positive integer N, (1000000 <= N <= 9999999).

출력 요약
The single output line consists of the word YES if the number should be routed to the directory information operator or NO if the number should not be routed to the directory information operator.

코드

print('YES'if input()[:3]=='555'else'NO')

설명

핵심은 구현 관점에서 In the United States of America, telephone numbers within an area code consist of 7 digits: the prefix number is the first 3 digits and the line numbe …를 만족하도록 로직을 구성하는 것입니다.

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

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



이런 주제는 어떠신가요?

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

댓글남기기