#P2056. ACSL 2019-2020 Senior Division Contest #1 Number Transformation
ACSL 2019-2020 Senior Division Contest #1 Number Transformation
Given a positive integer (call it ) and a position in that integer (call it ) transform . To transform , find the digit of from the right:
- Replace each of the digits to the left by the sum of that digit and the digit.
- Replace each of the digits to the right by the absolute value of the difference between it and the digit.
- Replace the digit by the number of different prime factors of . Note that is not a prime number, and it has no prime factors. A prime number has exactly one prime factor (namely, itself).
INPUT FORMAT
There will be sets of data. Each set contains two positive integers: and . will be less than , and will be valid.
OUTPUT FORMAT
The transformed value of each input set. The printed number may not have any spaces between the digits.
SAMPLE
INPUT
102438 3
4329 1
6710 2
16807 1
60098065452 7
OUTPUT
546414
1312113
7841
8131571
1488173823436