a53

Squary

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