Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<math.h>
- #include<map>
- #include<algorithm>
- #define ll long long int
- using namespace std;
- int main()
- {
- ll n,temp = 0,dem = 0;
- cin>>n;
- ll *a = new ll[n];
- for(long i = 0;i < n;i++) cin>>a[i];
- sort(a,a+n);
- for(long i = 0; i < n-1;i++)
- {
- if(a[i] == a[i+1]) temp++;
- else
- {
- temp++;
- //có n số nguyên ---> có n*(n-1) / 2 cặp tương ứng
- dem+= (temp*(temp-1))/2;
- temp = 0;
- }
- }
- cout<<dem;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement