您的位置:首页 > 其它

CodeForces 272B

2013-07-21 13:49 204 查看
2*a 相当将a的二进制中的数左移一个位置,末尾加0;
2*a 相当将2*a的末尾加1,2*a的末尾一定是0;
f[x] 就是计算x的二进制1的个数;

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int t;
cin >> t;
int f[100]= {0};
while(t--)
{
int n;
cin >> n;
int tot = __builtin_popcount(n);//计算二进制中有多少个1
f[tot]++;

}
long long ans = 0;
for(int i = 1; i <= 32; i++)
ans +=(long long)f[i]*(f[i]-1)/2;
cout << ans << endl;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: