Palindrome-Free Numbers
Time limit1sMemory limit128 MB
Count integers in [a, b] whose decimal representation has no palindromic substring of length 2 or more.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Implementation, Math, Brute force
- Solved
- No attempts yet
Problem
A string is called a palindrome if it reads the same forwards and backwards.
Write the decimal representation of an integer as a string of digits. If none of its substrings of length or more (contiguous digits) is a palindrome, then is called a palindrome-free number.
For example, is a palindrome-free number. On the other hand, is not, because its substring is a palindrome.
Given two integers and , write a program that counts how many palindrome-free numbers lie between and , inclusive.
Input
The first line contains two integers and , separated by a space. ()
Output
Print, on the first line, the number of palindrome-free integers that are at least and at most .