Youngjae's Walk
InterviewTime limit1sMemory limit512 MB
Simulate a walker who moves at speed v for one second, then turns right and updates v to (v*m)%10, and report the final coordinates after t seconds.
- Level
Medium4 of 10
- Topics
- Simulation, Implementation, Math, Brute force
- Solved
- No attempts yet
Problem
Youngjae likes solving algorithm problems. He is not very good at it, so he takes a walk when he cannot focus. Today he cannot focus again, so he walks around his neighborhood. His neighborhood is laid out on a two-dimensional coordinate plane.
Walking without any rule feels boring to Youngjae, so he decides to walk by a fixed rule.
If he walks at speed v at second t, he walks at speed v for 1 second. Then, the moment second t+1 begins, he turns 90 degrees to the right and walks at speed (v×m)%10. Given the initial speed v0, m, and the total walking time t, print Youngjae's final position. His starting position is (0, 0) and his starting direction is north.
North is the direction in which the y-coordinate increases, and east is the direction in which the x-coordinate increases.
Input
The initial speed v0, m, and the total walking time t are given.
Output
Print Youngjae's position after the walk ends.
Constraints
- 1 ≤ v0 ≤ 1,000
- 1 ≤ m ≤ 1,000
- 1 ≤ t ≤ 1,000,000,000
- v0, m, and t are integers