Cudan niz
Lovro wrote down the numbers from 1 to N. So it is written first, then all of a prime number, and then complicated so as to say
N = 6; read like 1 2 3 5 4 6, but that task would not be so easy there is a law called the DKL, which says that each number has its own "mass" and it is growing in this series!
The mass number is calculated by adding all its digits and total number of left and right side sequence.Number 1 has no mass.
Your task is to determine to help Lovro to write N-th member of this series.
Input
(N>0 N<100000)-N-th number of sequence
(N>0 N<100000)-N-th number of sequence
Output
Write N-th number of sequence
Write N-th number of sequence
Input:
Output:
8Output:
23Explanation of first example
1 2 3 4 5 6 7 8
----------------------
1 2 3 5 7 4 6 8
----------------------
1 6 10 15 16 17 18 23
----------------------------
1 6 10 15 16 17 18 23
23
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.