To solve the problem we need knowledge about how Loop works and some basic arithmetic operations. We need to do the following tasks:
Find each day’s spiders who will get fully recovered. And can calculate this using mod(%) operation, i.e (a1 % K)
Sum all of N day’s results we get from doing the task of above (1).
Time Complexity: O(TestCase * N)