Notice
Recent Posts
Recent Comments
Link
관리 메뉴

윤일무이

[백준-Python] 6810번: ISBN 본문

🥧 Python/⚙️ 코딩테스트

[백준-Python] 6810번: ISBN

썸머몽 2023. 3. 8. 14:20
728x90
 

6810번: ISBN

The International Standard Book Number (ISBN) is a 13-digit code for identifying books. These numbers have a special property for detecting whether the number was written correctly. The 1-3-sum of a 13-digit number is calculated by multiplying the digits a

www.acmicpc.net

 

📌 풀이

문제가 길게 적혀 있어서 약간 두려움이 느껴졌는데 그럴 문제는 아니다.

도서관 같은데 가면 ISBN 이라고 13자리 코드가 있는데 그걸 활용한 문제다.

예를 들어 1234567899999 13자리가 있다고 치면

1*1 + 2*3 + 3*1 ... 이런 식으로 맨 1곱하고 더하고 3곱하고 더하고 이런 형식이다.

주어진 문제는 이렇게 했을 때 합이 120이 나오는 것인데, 우리는 ISBN의 마지막 3자리를 가지고 이렇게 풀어야 한다.

마지막 세 자리는 9*1+4*3+8*1로 29이니까 120-29하면 91이다.

 

9, 4, 8을 입력했을 때 아래의 출력값대로 나올 수 있게 적어주면 된다.

 

✅ 코드

a = int(input())
b = int(input())
c = int(input())

print("The 1-3-sum is", 91 + a + b*3 + c)
728x90