//https://zerojudge.tw/ShowProblem?problemid=a020
//Captial letters ASCII code start from 65 to 90
#include <stdio.h>
#include <stdlib.h>//needed when using exit()
#include <string.h>
/*
(1) 英文代號以下表轉換成數字
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 台南縣 ***非連續
(2) 英文轉成的數字, 個位數乘9再加上十位數的數字
(3) 各數字從***右到左依次乘1、2、3、4....8 **僅8個
(4) 求出(2),(3) 及最後一碼的和
(5) (4)除10 若整除,則為 real,否則為 fake
例: T112663836
2 + 7*9 + 1*8 + 1*7 + 2*6 + 6*5 + 6*4 + 3*3 + 8*2 + 3*1 + 6 = 180
除以 10 整除,因此為 real */
char g_ID[11];//need 11 characters to store the ID and the null terminator "\0"
int REGtable[26] = {10, 11, 12, 13, 14, 15, 16, 17, 34, 18, 19, 20, 21, 22, 35, 23, 24, 25, 26, 27, 28, 29, 32, 30, 31, 33};
int REGnum;
int GET_REGnum(int R);
int GET_NUMProd(char l_id[11]);
int temp2;
int temp3;
int temp4;
int main()
{
scanf("%s", g_ID);// Strings don't need & in scanf
if (strlen(g_ID) != 10)
{
printf("fake\n");
return 0;
}
REGnum = GET_REGnum(g_ID[0]);
temp2 = (REGnum%10*9)+(REGnum/10);//using %10 to get single digits | And /10 for tens digits
temp3 = GET_NUMProd(g_ID);
temp4 = temp2+temp3+(g_ID[9]-'0');//**[]brackets can't be use in math operations
if(temp4%10 == 0)
{
printf("real\n");
}
else
{
printf("fake\n");
}
return 0;
}
int GET_REGnum(int R)
{
if(R<65 || R>90)
{
printf("fake\n");
exit(0);
}
return REGtable[R-'A'];
}
int GET_NUMProd(char l_id[])
{
int sum = 0;//initialize to avoid garbage value
for (int i = 1; i < 9; i++)//only first 8 numbers from the left
{
sum = sum+((l_id[i]-'0')*(9-i));
}
return sum;
}