Ryan is very indecisive. He is very fond of football and loves playing around with numbers, so he thought of using number manipulation as a way of making decisions.
On any given day Ryan would love to go play irrespective of the fact that its raining and that he has homework. He even stays up late at night watching matches. The only condition for him to play is that the day should be a magical day.
Take a number, reverse it, subtract the two and if the number thus obtained is evenly divisible by a specific number, the day is a magical day. For eg, take a number 13, its reverse is 31, their difference is 18 which if divided by 6 is perfectly divisible hence 13th is a magical day. He will look at a numbered range of days and will only play on a magical day.
Given a range of numbered days [m.....n] , and a number p , determine the number of days in the range that are magical. Magical numbers are defined as numbers where |m - reverse(m)| is evenly divisible by p . If a day's value is a magical number, it is a magical day. Print the sum of number of magical days in the range.
A single line of three space-separated integers describing the respective values of m , n, and p.
20 23 6
Only two days, 20 and 22, in this interval are magical. Thus, we print 2 as our answer.
Submit final ans as sum of answers of all below testcases.
Input: 13 45 3
Input: 1 123456 13
Input: 123 456789 189
Input: 1 2000000 23047885
Kunal Desai : 7715051136
Neelraj Patil : 9930671144