For the problem “KPRIME Problem - CodeChef”
Please can anyone tell why this link text is giving TLE for large I/P
complexity: O((b-a)*log(b-a)) for each test case
For the problem “KPRIME Problem - CodeChef”
Please can anyone tell why this link text is giving TLE for large I/P
complexity: O((b-a)*log(b-a)) for each test case
The link doesn’t seem to work. But anyway:
The constraints are a>=2, b<=100000 and T<= 10000.
So O((b-a)*log(b-a)*T) can yield a total number of operations of well above 10^9, which is far to much to compute in 1s on this platform.
Try to precompute smth. and get your time complexity per testcase down to O(1) or at worst O(log(b-a)).