Advertisement
tsypko

Untitled

Mar 24th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/rope>
  3. using namespace std;
  4. using namespace __gnu_cxx;
  5. typedef long long ll;
  6. typedef unsigned long long ull;
  7. typedef unsigned int ui;
  8. typedef long double ld;
  9. typedef pair<int, int> ii;
  10. typedef pair<ii, ii> iii;
  11. ll MOD = 1e9 + 9;
  12. const ld E = 1e-7;
  13. #define null NULL
  14. #define ms(x) memset(x, 0, sizeof(x))
  15. #ifndef LOCAL
  16. #define endl "\n"
  17. #endif
  18. #ifndef LONG_LONG_MAX
  19. #define LONG_LONG_MAX LLONG_MAX
  20. #endif
  21. #define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  22. #define _read(x) freopen(x, "r", stdin)
  23. #define _write(x) freopen(x, "w", stdout)
  24. #define files(x) _read(x ".in"); _write(x ".out")
  25. #define filesdatsol(x) _read(x ".dat"); _write(x ".sol")
  26. #define output _write("output.txt")
  27. #define input _read("input.txt")
  28. #define prev time_prev
  29. #define M_PI acos(-1)
  30. #define remove tipa_remove
  31. #define left tipa_left
  32. #define right tipa_right
  33. #define next tipa_next
  34. #define mod % MOD
  35. #define y1 hello_world
  36. unsigned char ccc;
  37. bool _minus = false;
  38. template<typename T>
  39. inline T sqr(T t) {
  40. return (t * t);
  41. }
  42. inline void read(ll &n) {
  43. n = 0;
  44. _minus = false;
  45. while (true) {
  46. ccc = getchar();
  47. if (ccc == ' ' || ccc == '\n')
  48. break;
  49. if (ccc == '-') {
  50. _minus = true;
  51. continue;
  52. }
  53. n = n * 10 + ccc - '0';
  54. }
  55. if (_minus)
  56. n *= -1;
  57. }
  58. inline void read(int &n) {
  59. n = 0;
  60. _minus = false;
  61. while (true) {
  62. ccc = getchar();
  63. if (ccc == ' ' || ccc == '\n')
  64. break;
  65. if (ccc == '-') {
  66. _minus = true;
  67. continue;
  68. }
  69. n = n * 10 + ccc - '0';
  70. }
  71. if (_minus)
  72. n *= -1;
  73. }
  74. char wwww[19];
  75. int kkkk;
  76. inline void write(ll y) {
  77. long long x = y;
  78. kkkk = 0;
  79. if (x < 0) {
  80. putchar('-');
  81. x *= -1;
  82. }
  83. if (!x)
  84. ++kkkk, wwww[kkkk] = '0';
  85. else
  86. while (x) {
  87. ++kkkk;
  88. wwww[kkkk] = char(x % 10 + '0');
  89. x /= 10;
  90. }
  91. for (int i = kkkk; i >= 1; --i)
  92. putchar(wwww[i]);
  93. }
  94.  
  95. #ifdef LOCAL
  96. #define DEBUG
  97. #endif
  98.  
  99. #ifdef DEBUG
  100. #define dbg if(1)
  101. #else
  102. #define dbg if(0)
  103. #endif
  104.  
  105. const int MAX = 1e6 + 10;
  106.  
  107. int n;
  108. ll t[MAX], ar[MAX];
  109. bool used[MAX];
  110.  
  111. ll q[MAX];
  112.  
  113. int main() {
  114. sync;
  115. srand(time(NULL));
  116. cout.precision(3);
  117. cout << fixed;
  118. #ifdef LOCAL
  119. input;
  120. #else
  121.  
  122. #endif
  123.  
  124. for(int i = 2; i < MAX; i++){
  125. if(!used[i]){
  126. q[i] = (rand() * (1LL << 45)) ^ (rand() * (1LL << 32)) ^ (rand() << 16) ^ rand();
  127. for(int j = i; j < MAX; j += i){
  128. int z = j;
  129. used[z] = true;
  130. while(z % i == 0){
  131. t[j] ^= q[i];
  132. z /= i;
  133. }
  134. }
  135. }
  136. }
  137.  
  138. cin >> n;
  139.  
  140. for(int i = 1; i <= n; i++){
  141. cin >> ar[i];
  142. }
  143.  
  144. map<ll, int> m;
  145. m[0] = 1;
  146.  
  147. ll ans = 0;
  148. ll sum = 0;
  149. for(int i = 1; i <= n; i++){
  150. sum ^= t[ar[i]];
  151. ans += m[sum]++;
  152. }
  153.  
  154. cout << ans << endl;
  155.  
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement