Alf and the Chalkboard
InterviewTime limit2sMemory limit1024 MB
Starting from n, each minute adds the number's last digit to it. Find the number on the board after k minutes.
- Level
Easy3 of 10
- Topics
- Simulation, Math
- Solved
- No attempts yet
Statement
Alf saw a classroom chalkboard for the first time in his life. He realized he could write whatever he wanted on it with chalk, then erase it and write something new.
Alf wrote a number on the board. Then he decided to have some fun. Every minute he adds the last digit of the current number to it, erases the old number, and writes the new one. Alf got tired quickly, but he is very curious, so he wants to know which number he would have written after minutes.
Help Alf. Otherwise he will be disappointed.
Input
A single line contains two integers and (), the starting number and the number of minutes.
Output
Print one number , the number on the board after minutes.