반응형
Notice
Recent Posts
Recent Comments
Link
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Today
Total
11-07 11:40
관리 메뉴

ImJay

[파이썬/Python] 백준 6810번 ISBN 본문

Solved.ac - Python/Bronze V

[파이썬/Python] 백준 6810번 ISBN

ImJay 2022. 11. 15. 11:44
반응형

[파이썬/Python] 백준 6810번 ISBN

 

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


문제

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 alternately by 1’s and 3’s (see example) and then adding the results. For example, to compute the 1-3-sum of the number 9780921418948 we add

9 ∗ 1 + 7 ∗ 3 + 8 ∗ 1 + 0 ∗ 3 + 9 ∗ 1 + 2 ∗ 3 + 1 ∗ 1 + 4 ∗ 3 + 1 ∗ 1 + 8 ∗ 3 + 9 ∗ 1 + 4 ∗ 3 + 8 ∗ 1

to get 120.

The special property of an ISBN number is that its 1-3-sum is always a multiple of 10.

Write a program to compute the 1-3-sum of a 13-digit number. To reduce the amount of typing, you may assume that the first ten digits will always be 9780921418, like the example above. Your program should input the last three digits and then print its 1-3-sum. Use a format similar to the samples below.

코드

N1 = int(input())
N2 = int(input())
N3 = int(input())

sum = 91 + N1 + N2*3 + N3
print("The 1-3-sum is", sum)

풀이

1. ISBN number의 마지막 세자리 N1, N2, N3 값을 입력 받습니다.

N1 = int(input())
N2 = int(input())
N3 = int(input())

 

2. 1-3-sum 을 출력합니다.

앞 10자리는 생략되어 있습니다. (합 91)

뒷 3자리를 1-3-sum 규칙에 따라 연산하여 구합니다.

sum = 91 + N1 + N2*3 + N3
print("The 1-3-sum is", sum)

 

반응형
Comments