#35838: PYTHON答案 寫得很簡單


chiren0000@gmail.com (relxis)

學校 : 不指定學校
編號 : 236030
來源 : [1.173.208.60]
最後登入時間 :
2023-06-18 22:40:35
a020. 身分證檢驗 | From: [1.173.208.60] | 發表日期 : 2023-06-18 22:46

id = input()
dict = {"A": 10, "J": 18, "S": 26, "B": 11, "K": 19, "T": 27, "C": 12, "L": 20, "U": 28, "D": 13, "M": 21, "V": 29, "E": 14,"N": 22, "W": 32, "F": 15, "O": 35, "X": 30, "G": 16, "P": 23, "Y": 31, "H": 17, "Q": 24, "Z": 33, "I": 34, "R": 25} #建立字典

number = dict[id[0]] # 對照字典 將身分證的英文字母轉換為數字
num1 = number // 10 # 數字的十位數
num2 = number % 10 # 數字的個位數

total_num = num1 + num2 * 9 + int(id[9]) # 先把題目要求的第2步以及最後一碼相加

for i in range(1, 9): #加上第三步
    total_num = total_num + int(id[i]) * (9-i)

real = (total_num % 10 == 0) #定義boolean值 real 判斷total_num是否整除10

if (real): # 輸出
    print("real")
else:
    print("fake")
 
ZeroJudge Forum