https://ide.codingblocks.com/#/s/29815
this is my code for https://hack.codingblocks.com/contests/c/512/266
Please tell me where am i going wrong in my logic as the o/p is not correct.Thanks.
Arrays-divisible subarrays
- size of a is too small, make it 10^6
- if(sum%N==0) condition must be outside k loop inside j loop
- Take long long.
This would work and give correct output, but will give time limit exceed and you are solving it in O(N^3) and you are supposed to solve it in O(N).
First correct the code and then try some other approach. Comment here if you face any trouble.
Thanks, I wanted help with the logic part only. I was coding in my system’s IDE, that’s why i didn’t take long long at the moment. However, it is not working for the 1st test case mentioned in the link.
for 1st test case-
5
1 1 1 1 1
it prints 4, whereas the correct ans is 5.
see this-
https://ide.codingblocks.com/#/s/29930
yes, got them, a big thanks to you again.
1 Like