백준: 6810번 ISBN (Python3)
ISBN 성공다국어
1 초 | 128 MB | 1334 | 933 | 867 | 70.146% |
문제
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.
예제 입력 1
9
4
8
예제 출력 1
The 1-3-sum is 120
답안
1
2
3
4
5
|
a=int(input())
b=int(input())*3
c=int(input())
pr = f'The 1-3-sum is {a+b+c+91}'
print(pr)
|
cs |
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 8558번 Silnia (Python3) (0) | 2022.08.03 |
---|---|
백준: 7891번 Can you add this? (Python3) (0) | 2022.08.03 |
백준: 6778번 Which Alien? (Python3) (0) | 2022.08.03 |
백준: 6764번 Sounds fishy! (Python3) (0) | 2022.08.03 |
백준: 6763번 Speed fines are not fine! (Python3) (0) | 2022.08.03 |
댓글