14303 - Natioanl ID Validation   

Description

This is an advanced problem.

 

In Taiwan, national identification numbers are not randomly assigned. Valid national identification numbers must pass a verification process to make sure they are real ID numbers. Only those that pass this verification process are considered as valid national identification numbers. 

A national ID number consists of an alphabet and 9 digits.
The unified ID number of the national identity card can be verified through the following formula:

  • Transform the alphabet into two digits (a1, a2) e.g A-> 10
Alphabet  Number(a1, a2)
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
  • The 9 digits represent as n1-n9
  • Convert the alphabets into numerical values and multiply them by 1, 9. Then, multiply the nine Arabic numerals (n1-n9) by 8, 7, 6, 5, 4, 3, 2, 1, 1 respectively, and sum them up.
  • N = a1*1 + a2*9 + n1*8 + n2*7 + n3*6 + n4*5 + n5*4 + n6*3 + n7*2 + n8*1 + n9*1
  • If N is the multiple of 10 it's a valid national ID number.

Input

You will get many national ID numbers, and not sure of the numbers of the ID numbers.
All the valid ID numbers' alphabet will be in the range:{A - G} and uppercase.

Output

Please validate the ID. After validating all ID numbers, rerun a string.
The string consists of all the alphabets of valid ID numbers and the sum of the numbers of valid IDs. The alphabets should be in the same order of input.

Take the example input as example:

Only the first 4 ID are valid.
A154712712    (O)
A166672796    (O)
E163326166    (O)
B117025840    (O)
456    (X)
x1234567895    (X)
C520149873    (X)

Only the first 4 IDs are correct.
The answer should be the first 4 IDs' alphabets (AAEB) combine with the sum of first 4 IDs' numbers (154712712+166672796+163326166+117025840 = 601737514)
=> AAEB601737514

Sample Input  Download

Sample Output  Download

Tags




Discuss