赞
踩
异或相等,即为两数相等,统计累计答案即可
#include<bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define inf 0x3f3f3f3f const int mod=1e9+7; const int N=2e5+5; int n,m; int a[N]; map<int,int>mp; void solve(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; mp[a[i]]++; } int ans=n; for(auto it:mp){ int t=it.second; ans+=t*(t-1); } cout<<ans; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int tt=1; // cin>>t; while(tt--) solve(); return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。