728x90
9907번: ID
The National Identity Card number of the city state of Eropagnis, NICE, consists of seven digits and a letter appended behind. This letter is calculated from the digits using the Modulo Eleven method. The steps involved in the computation are as follows:
www.acmicpc.net
문제 풀이
문제에 주어진대로 입력값의 각 자릿수마다 숫자를 곱해준 뒤, 그 합을 11로 나눈 나머지를 "JABCDEFHIZ"의 인덱스로 매핑한다.
정답 코드
id_map = "JABCDEFGHIZ"
s = input()
id = int(s[0]) * 2 + int(s[1]) * 7 + int(s[2]) * 6 + int(s[3]) * 5 + int(s[4]) * 4 + int(s[5]) * 3 + int(s[6]) * 2
print(id_map[id % 11])
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 9945 - Centroid of Point Masses [python] (0) | 2023.03.28 |
---|---|
[BOJ/백준] 9924 - The Euclidean Algorithm [python] (0) | 2023.03.28 |
[BOJ/백준] 9848 - Gift [python] (0) | 2023.03.28 |
[BOJ/백준] 9838 - XMAX [python] (0) | 2023.03.27 |
[BOJ/백준] 9783 - Easy Encryption [python] (0) | 2023.03.27 |