Processing math: 66%
Solutions of Equal pairs - MarisaOJ: Marisa Online Judge

Solutions of Equal pairs

Select solution language

Write solution here.


MayFreecs    Created at    5 likes

# explanation ## how to count number of pairs using frequency In order to count how many pairs there are depending on the frequency of a number we use this formula: pairs=frequencyβˆ—(frequencyβˆ’1)/2 Also let's not forget to use long long instead of int since we are dealing with 105 values therefore the max value is around  (105)2, which is bigger than an int can support Now that we know this, let's implement it # Solution #∈clude<bitsstdc++.h>#def∈e∫longlongusingnamespacestd;sigβ‰ dma∈(){∫n,j;c∈βŒͺn;/idecdΒ¬β†’sβ†’reallvalues∈aβ†’β†’r,youcandotΛ†βˆ«max