We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For anyone that wishes for a little more background like I did on this stuff, I found the explanations of modular arithmetic on Khan Academy really helpful.
for(inti=0;i<n;i++){cin>>a[i];m[a[i]%k]++;}
This above piece of code is just finding the amount of elements in each "equivalence class" and all code after that is taking advantage of the addition property of modular arithmetic:
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
For anyone that wishes for a little more background like I did on this stuff, I found the explanations of modular arithmetic on Khan Academy really helpful.
This above piece of code is just finding the amount of elements in each "equivalence class" and all code after that is taking advantage of the addition property of modular arithmetic:
Hope this helps out there! Great solution!