Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

Generating Palindrome

Revision en1, by aman_naughty, 2019-09-11 18:37:35

I have a problem: Given two numbers in l and r where l<=r and can be as large as 1e18, I want to count the number of palindrome numbers in the range l to r such that they are a square of some palindrome number.

For example, I have L=4 and R=1000

ans = 4 , numbers are 4, 9, 121, 464.

My code:

code

I am getting the wrong answer on this test case

L=92904622 R=232747148

My answer is 3 but the correct answer is 6.

My approach is to generate all palindromes of length at most 10 and then check if their square is also a palindrome.

Can someone point out what am I doing wrong??

Any help is appreciated.

Tags #palindrome, #interview, #brute force

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English aman_naughty 2019-09-11 19:32:53 318
en1 English aman_naughty 2019-09-11 18:37:35 691 Initial revision (published)