@akhon
Because u are iterating till D which can be as big as 10^6 and the number of test cases is 10^5 so the total complexity will become 10^11 which is too much so u have to think of some mathematical solution that can be done in O(1) inside test case loop . Overall u r not allowed to iterate something in this test case because of high constraint.
But dont we usually ignore the number of test cases for writing code? Like for any ‘n’ less than 10^9 the code shouldn’t really give TLE error no? I remember doing the same and getting no TLE error.
Yes u r right but in such question they have mentioned like the size of tn would not exceed 10^5 or 6 like that. In this case they haven’t mentioned then u have to include t in your time complexity or not.
For ex:-
see this question in the constraints section last point they have mentioned that the Sum of N over all test cases does not exceed 210^5.