CF272B Dima and Sequence
题目描述
Dima被数列吸引住了。现在他有一个数列$a_1, a_2, ..., a_n$,由$n$个正整数组成。Dima还有一个函数$f(x)$,其定义如下:
- $f(0) = 0$;
- $f(2·x) = f(x)$;
- $f(2·x + 1) = f(x) + 1$
Dima想知道有多少对数$(i, j)(1 \leq i < j \leq n)$满足$f(a_i) = f(a_j)$。请帮助Dima求出这种对数的个数。
输入格式
第一行包含一个整数$n (1 \leq n \leq 10^5)$。
第二行包含$n$个被单个空格隔开的正整数$a_1, a_2, ..., a_n(1 \leq a_i \leq 10^9)$。
输出格式
一个数,代表如上所述的对数的个数。
温馨小提示:在C++不要使用`%lld`来读写64位的整数。推荐使用输入输出流或`%l64d`。
说明/提示
In the first sample any pair $ (i,j) $ will do, so the answer is $ 3 $ .
In the second sample only pair $ (1,2) $ will do.