Created
February 14, 2013 10:46
-
-
Save rohith2506/4951965 to your computer and use it in GitHub Desktop.
codeforces 167 div2 problem B:-
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
#include <vector> | |
#include <cmath> | |
typedef long long int LL; | |
#define MAX 100100 | |
LL arr[MAX]; | |
using namespace std; | |
int f(int a){ | |
if(a==0) return 0; | |
if(a%2==0) return f(a/2); | |
return f(a/2)+1; | |
} | |
int main(){ | |
int n; | |
cin>>n; | |
for(int i=0;i<n;i++){ | |
int a; | |
cin>>a; | |
arr[f(a)]++; | |
} | |
LL res=0; | |
for(LL i=0;i<MAX;i++){ | |
LL x=arr[i]; | |
LL prod=(x*(x-1))/2; | |
res+=prod; | |
} | |
cout<<res<<endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment