Sir..I tried the below question ..I got the correct answer for all test cases.but I got TLE due to constraints..then I saw some users solutions..they did that problem with a formula...but I wonder what is that formula....could any one explain how to get AC with in time limit..and explain that formula clearly..how did they get it. https://www.codechef.com/PROCON15/problems/PRCNSR1
Thanks