Modulo problem in peer section

Can someone plz tell me why its giving runtive error? Problem code: NSIT13 Link: CodeChef: Practical coding for everyone

I have seen your code. Read problem statement. There is 10 test case and for each test case there is 10 non-negative integer. So for each test case t will be 10. But you initialize t at first and it will work for only one test case. So initialize t every time into first loop. After that correction you will get wrong answer. This is because you initialize arr[] with 0. your program will give wrong answer when b will be 0, that’s means when a%42=0. After that when you count copy of b in arr[] you have not deleted the copy item. So next time when you get b as same as before, you will count copy of b twice that are counted before. So it will give wrong answer. Then when you insert b you have insert multiple time. Let your array is 5 0 0 0 0 0 and 10-t=5 and b=0, then your program will insert b in every place of 0 and increase value of c. So it will give you Wrong answer.After inserting b you have to break the loop. Hope you have get it.
If you know use of set then there is a simple solution. You can check this CodeChef: Practical coding for everyone
For further information a set contain only unique elements in increasing order.

1 Like

Thank you so much