Hello... I got TLE on the following problem. I myself found out that it's taking an awful amount of time for inputs with eight or nine digits! How can I optimize my code and reduce the complexity? I tried to devise a formula, but couldn't go anywhere. I can still try if any of you could tell me how to approach...
Thanks in advance.
You need to find a formula to solve this problem, you can't iterate over 109 elements.
That simple!! Thanks a lot...