By Alexandre Campos, UNIUBE Brazil
You are about to write a program to predict a CPF, which, in Brazil, is equivalent to Social Security Number. It is composed by 11 digits and the lasts two (verification digits) are function of the nine previous. In this way, if a person informs a CPF, by mistake or on purpose, it is possible to find out. Let us introduce some notation. Let a CPF be
a1 a2 a3 . a4 a5 a6 . a7 a8 a9 - b1 b2
To get b1, one can multiply a1 by 1, a2 by 2, a3 by 3, so on, up to a9 by 9 and sum these results. Then, b1 is the remaining of this number when divided by 11, or 0 in case the remaining is 10.
Analogously, to get b2, one can multiply a1 by 9, a2 by 8, a3 by 7, so on, up to a9 by 1 and sum these results. Then, b2 is the remaining of this number when divided by 11, or 0 in case the remaining is 10.
The input is composed by an unknown number of sequences in the form:
a1a2a3a4a5a6a7a8a9
Each sequence represents the 9 firsts digits of a CPF.
For each sequence, you have to print the input sequence and the verification digits formated as
a1a2a3.a4a5a6.a7a8a9-b1b2
Input Sample | Output Sample |
000000000 |
000.000.000-00 |