Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. map <long long,long long> mp;
  4. long long sol,sum_xor;
  5. const int VALMAX=300;
  6. bool use[VALMAX+5];
  7. vector <int> prime;
  8. int n,x;
  9. int main()
  10. {
  11. ios::sync_with_stdio(0);
  12. cin.tie(0);
  13. for(int i=2;i<=VALMAX;i++)
  14. {
  15. if(!use[i])
  16. {
  17. prime.push_back(i);
  18. for(int j=i+i;j<=VALMAX;j+=i)
  19. use[j]=1;
  20. }
  21. }
  22. cin>>n;
  23. mp[0]=1;
  24. for(int i=1;i<=n;i++)
  25. {
  26. cin>>x;
  27. long long val=0;
  28. for(int j=0;j<(int)prime.size() && x>1;j++)
  29. {
  30. int nr=0;
  31. while(x%prime[j]==0)
  32. {
  33. nr++;
  34. x/=prime[j];
  35. }
  36. if(nr%2)
  37. val|=(1LL<<j);
  38. }
  39. sum_xor^=val;
  40. if(mp.count(sum_xor))
  41. sol+=mp[sum_xor];
  42. mp[sum_xor]++;
  43. }
  44. cout<<sol;
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement