Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <vector>
- #define VALMAX 300
- using namespace std;
- map <long long,long long> mp;
- long long sol,sum_xor;
- bool use[VALMAX+5];
- vector <int> prime;
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- for(int i=2;i<=VALMAX;++i)
- {
- if(!use[i])
- {
- prime.push_back(i);
- for(int j=i+i;j<=VALMAX;j+=i)
- use[j]=1;
- }
- }
- int n;
- cin>>n;
- mp[0]=1;
- int x;
- for(int i=1;i<=n;++i)
- {
- cin>>x;
- long long val=0;
- for(int j=0;j<(int)prime.size()&&x>1;++j)
- {
- int nr=0;
- while(x%prime[j]==0)
- ++nr,x/=prime[j];
- if(nr%2)
- val|=(1LL<<j);
- }
- sum_xor^=val;
- if(mp.count(sum_xor))
- sol+=mp[sum_xor];
- ++mp[sum_xor];
- }
- cout<<sol;
- return 0;
- }
Add Comment
Please, Sign In to add comment