#P12178. DerrickLo's Decimals (UBC002A)
DerrickLo's Decimals (UBC002A)
Description
There is a pure recurring decimal whose recurring period has a length of . This number can be written as .
Due to some strange problems of Nailoong, DerrickLo's computer faced some accuracy issues, that is, when he is asking for the value of , the computer only tells him digits , where shows the last digit when rounding to the digit after floating point.
DerrickLo wants you to calculate the sum of all the possible values of . To reduce output, output the sum multiplied by .
Note that when rounding a decimal to an integer, we only consider the value of at most one digit right to the floating point. If we let be the function of rounding, then hold.
Formally, .
Input Format
The input is consisted of two lines.
The first line contains one single integer , the length of the recurring period.
The second line is consisted of integers separated by a space, .
Output Format
One line, consisting of one number showing the answer.
It can be shown that the answer is always an integer whose number of digits is not greater than .
If its number of digit is less than , output zeros right before the answer (without any spaces).
4
0 1 3 2
0132
4
6 9 8 7
5876
Hint
Testcase 1
Let .
- When rounding to the 1st digit, , the 1st digit is .
- When rounding to the 2nd digit, , the 2nd digit is .
- When rounding to the 3rd digit, , the 3rd digit is .
- When rounding to the 4th digit, , the 4th digit is .
Thus satisfies the constraints.
It can be proven that there aren't any possibles values other than that can be the value of . So, the sum is . After multiplying it by , it becomes , so you should output 0132.
Testcase 2
Let .
- When rounding to the 1st digit, , the 1st digit is .
- When rounding to the 2nd digit, , the 2nd digit is .
- When rounding to the 3rd digit, , the 3rd digit is .
- When rounding to the 4th digit, , the 4th digit is .
Thus satisfies the constraints.
It can be proven that there aren't any possibles values other than that can be the value of , so the sum is . After multiplying it by , it becomes , so you should output 5876.
Constraints
For all testcases, .
京公网安备 11011102002149号