非常簡單(真的(沒騙你))
基礎題,適合初學者練習條件判斷與加權計算
首位英文字母轉換為兩位數字後,依照規則加權計算。
最後判斷總和是否能被 10 整除。
# 英文字母對應的數值表
letter_map = {
'A':10, 'B':11, 'C':12, 'D':13, 'E':14, 'F':15, 'G':16, 'H':17, 'I':34, 'J':18,
'K':19, 'L':20, 'M':21, 'N':22, 'O':35, 'P':23, 'Q':24, 'R':25, 'S':26, 'T':27,
'U':28, 'V':29, 'W':32, 'X':30, 'Y':31, 'Z':33
}
while True:
try:
id_str = input().strip()
if len(id_str) != 10 or id_str[0] not in letter_map:
print("fake")
continue
# 將英文字母轉換為兩位數字
n = letter_map[id_str[0]]
total = (n // 10) + (n % 10) * 9
# 加上後九碼的加權值
for i in range(1, 9):
total += int(id_str[i]) * (9 - i)
# 加上最後一碼(檢查碼)
total += int(id_str[9])
# 判斷是否整除
if total % 10 == 0:
print("real")
else:
print("fake")
except EOFError:
break