Reversed Multiplication Table
InterviewTime limit1sMemory limit128 MB
For a multiple N, reverse the decimal digits of N*1 through N*K and print the largest resulting value, dropping leading zeros.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
In an ordinary multiplication table the last term holds the largest value. In a reversed multiplication table each term stores the product with its decimal digits written in reverse order, so the largest value is not always the last one.
For example, the nine terms of the table of 8 are 8, 16, 24, 32, 40, 48, 56, 64, 72, and 72 is the largest among them. In the reversed table the same terms become 8, 61, 42, 23, 4, 84, 65, 46, 27, and the largest value is 84. Reversing 40 gives 04, and the zero left at the front is dropped, so that term counts as 4.
You are given the table number and the number of terms . Write a program that prints the largest number obtained by reversing each of through .
Input
The first line contains and , separated by a space. Both are natural numbers not greater than 1,000.
Output
Print the largest value among the first terms of the reversed multiplication table of on the first line.