CF272B.Dima and Sequence
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Dima got into number sequences. Now he's got sequence _a_1, _a_2, ..., a__n, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:
- f(0) = 0;
- f(2·x) = f(x);
- f(2·x + 1) = f(x) + 1.
Dima wonders, how many pairs of indexes (i, j) (1 ≤ i < j ≤ n) are there, such that f(a__i) = f(a__j). Help him, count the number of such pairs.
迪马开始研究数列。现在他得到了一个由 n 个正整数组成的数列 a1,a2,…,an。此外,迪马还定义了一个函数 f(x),其递推关系如下:
- f(0)=0;
- f(2⋅x)=f(x);
- f(2⋅x+1)=f(x)+1。
迪马想知道:满足 f(ai)=f(aj) 的下标对 (i,j)(其中 1≤i<j≤n)有多少个?请帮他计算这样的数对个数。
输入格式
The first line contains integer n (1 ≤ n ≤ 105). The second line contains n positive integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 109).
The numbers in the lines are separated by single spaces.
第一行包含一个整数 n(1 ≤ n ≤ 105)。第二行包含 n 个正整数 a1,a2,...,an(1 ≤ ai ≤ 109)。
每行中的数字以单个空格分隔。
输出格式
In a single line print the answer to the problem.
Please, don't use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
在一行中输出问题的答案。
请注意,在 C++ 中不要使用 %lld 说明符读取或写入 64 位整数。推荐使用 cin、cout 流,或 %I64d 说明符。
输入输出样例
输入#1
3 1 2 4
输出#1
3
输入#2
3 5 3 1
输出#2
1
说明/提示
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.
在第一个样例中,任意一对 (i,j) 均可满足要求,因此答案为 3。
在第二个样例中,仅有对 (1,2) 满足要求。
输入解题思路,AI测评打分。不知道怎么写?