#AJ1901. Number Transformation (初级)
Number Transformation (初级)
Description
Given a positive integer , a position in that integer , and a transition integer , transform according to the following rules:
- Count from the right side of to find the digit.
- If the digit is from 0 to 4:
- Add to the digit.
- Replace the digit with the units digit of the sum.
- Replace all digits to the right of the digit with 0.
- If the digit is from 5 to 9:
- Subtract from the digit.
- Calculate the absolute value of the difference.
- Replace the digit with the leftmost digit of that absolute value.
- Replace all digits to the right of the digit with 0.
Input Format
There will be 5 sets of data. Each set contains 3 positive integers: , , and .
- will be less than .
- and will be valid inputs.
- No input will cause an output to have a leading digit of 0.
Output Format
For each set of inputs, print the transformed number. The printed number may not have any spaces between the digits.
Explanation
Example 1: , , . The digit from the right is 3 (which is between 0 and 4). Add 8 to it: . The units digit is 1. Replace 3 with 1 to get 7145012. Replace digits to the right with 0s to get 7145010.
Example 2: , , . The digit from the right is 6 (which is between 5 and 9). Subtract 54: . Absolute value is 48. The leftmost digit is 4. Replace 6 with 4 to get 1540470. Replace digits to the right with 0s to get 1540400.
124987 2 3
124950
540670 3 9
540300
7145042 2 8
7145020
124987 2 523
124950
4386709 1 2
4386707