Hello, everyone. I have spent quite some time to solve this problem, “Modulo Equality”

( https://www.codechef.com/problems/EQUALMOD ).

I did this by finding the minimum of all the elements in B. After that, I loop through 0 to minimum and check how many operations I have to do to get every number in A so that remainder is that number (the number in the loop, i.e., from 0 to min). This approach gets me TLE. I saw solutions of fellow mates and came across these suffixes and prefixes they calculate. I did not understand what is going on. Can anyone please explain it to me?

# I am facing difficulty solving this problem.

**lousy**#1

**art_hack**#2

This is a question from ICPC 2017, so its editorial can be found here: https://discuss.codechef.com/questions/122233/equalmod-editorial. Please search a bit before posting in the future.