#37415: python程式


q0908309831@gmail.com (浪人飄飄)

學校 : 不指定學校
編號 : 234983
來源 : [140.118.154.127]
最後登入時間 :
2023-11-15 14:44:05
a020. 身分證檢驗 | From: [140.118.74.187] | 發表日期 : 2023-09-06 23:17

ide = input().strip()
count = 9 #數字從右到左乘1到8,代表從左到右乘8到1
Num = 0

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} #建立字典
for i in ide:
  if count == 9: #因為一開始一定是英文
    EN = str(dict[i]) #紀錄英文數字,並拆開轉字串
    Num = eval("{}+{}*9".format(EN[0],EN[1])) #計算出第一碼
  elif count == 0:
    Num = Num + int(i)
  else:
    Num = Num + int(i) * count

  count = count - 1
if Num % 10 == 0:
  print("real")
else:
  print("fake")
 
如果有更好的優化,麻煩請跟我說,謝謝
 
ZeroJudge Forum