Divisible subarray(Getting output as lots of zeroes)


The last for loop is not being executed(I checked).
I am unable to figure out the problem.

Ashish, firstly use a function to calculate the values, since you are doing everything inside a main, it is giving static value of ans as 0 only. I have modified your code a bit, now it is giving two output values only, but u need to make a separate function for calculating ans,

No, we can do everything inside a main function. The thing is that I scanned the value of t instead of n inside the while loop. I changed that and now it’s fine.

are you facing any difficulty in solving the question now ?

NO it’s working fine now.

But one test case gives wrong answer. Reply