Problem link
Let's transform condition a little bit. , so the condition is equivalent: That's why we just need to count the number of pairs of equal numbers in the array
⇔a4i−a4j≡kai−kaj
⇔a4i−kai≡a4j−kaj
. It's easy to do it, for example, using map. Complexity or .
A solution in c++


0 Comments
If you have any doubts, Please let me know