Problem Statement | |||||||||||||
First of all we define a function dig for all nonnegative integers:dig(x) := x if 0 <= x <= 9 dig(x) := dig(sum of digits of x) if x >= 10For example: dig(49) = dig(13) = dig(4) = 4. Your crew of treasure hunters have recently found a very old map with instructions on how to find the treasure of an old civilization. There is a variable named Gold number, and it is initially assigned a value of 1. You are currently standing at position (0, 0), facing north. Repeat the following instructions K times: 1. Take dig(Gold number) steps forward, and then turn 90 degrees right. 2. Multiply Gold number by multi. Each step forward moves you one unit in your current direction. Moving north changes your location by (0, 1), south changes your location by (0, -1), west changes your location by (-1, 0) and east changes your location by (1, 0). After you perform all the instructions, you can start digging. Return the coordinates (X, Y) of your final location as a String in the form "X Y" (quotes for clarity), where X and Y contain no extra leading zeroes. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | K will be between 1 and 10^9, inclusive. | ||||||||||||
- | multi will be between 1 and 1000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
|