Advertisement
TheKabeton

Untitled

Nov 15th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. /*-------------------- Code written by Kabeton --------------------*/
  2. /*--- Contacts: https://vk.com/kabeton and TheKabeton@yandex.ru ---*/
  3.  
  4. #define _USE_MATH_DEFINES
  5. #include <iostream>
  6. #include <iomanip>
  7. #include <cstdio>
  8. #include <cstdlib>
  9. #include <cmath>
  10. #include <algorithm>
  11. #include <vector>
  12. #include <map>
  13. #include <unordered_map>
  14. #include <set>
  15. #include <bitset>
  16. #include <tuple>
  17. #include <queue>
  18. #include <stack>
  19. #include <valarray>
  20. #include <sstream>
  21. #include <cstring>
  22. #include <numeric>
  23. #include <ctime>
  24. #include <cassert>
  25.  
  26. using namespace std;
  27.  
  28. #define endl "\n"
  29. #define re return
  30. #define fi first
  31. #define se second
  32. #define all(a) a.begin(), a.end()
  33.  
  34. typedef long long ll;
  35. typedef unsigned long long ull;
  36. typedef long double ld;
  37. typedef pair<ll, ll> pll;
  38. typedef vector<ll> vll;
  39. typedef vector<vll> vvll;
  40. typedef vector<pll> vpll;
  41. typedef vector<vpll> vvpll;
  42.  
  43.  
  44. const ll mod = 1e9 + 7;
  45. const ll inf = 1e15;
  46.  
  47.  
  48. int main() {
  49. ios::sync_with_stdio(false);
  50. cin.tie(nullptr);
  51. cout.tie(nullptr);
  52.  
  53. ll t;
  54. cin >> t;
  55.  
  56. for (ll i = 0; i < t; ++i) {
  57. ll ans = 0;
  58. ll n;
  59. cin >> n;
  60. map<pair<ll, ll>, vector<pair<long double, pair<ll, ll>>>> mp;
  61.  
  62. ll x, y, a, b;
  63. for (ll q = 0; q < n; ++q) {
  64. cin >> x >> y >> a >> b;
  65. if (x == 0 && y == 0) {
  66. mp[{0, 0}].push_back({-1, {a, b}});
  67. for (auto &k : mp[{a, b}]) {
  68. if (k.second.first == 0 && k.second.second == 0) {
  69. ++ans;
  70. }
  71. }
  72. } else {
  73. ll sq = x * x + y * y;
  74. long double alhpa = asin(y / sqrt(sq));
  75. mp[{x, y}].push_back({alhpa, {a, b}});
  76. for (auto &k : mp[{a, b}]) {
  77. if (k.second.first == x && k.second.second == y && k.first < 0.000000001) {
  78. ++ans;
  79. }
  80. }
  81. for (ll j = 0; j * j <= sq; ++j) {
  82. ll k = sq - j * j;
  83. auto sk = sqrt(k);
  84. if (abs(k - (ll)(sk + 0.000000001)) < 0.000000001) {
  85. ll xx = j, yy = (ll)(sk + 0.000000001);
  86. long double alhpa2 = asin(yy / sqrt(sq));
  87. if (alhpa2 < alhpa) {
  88. alhpa2 += M_PI * 2;
  89. }
  90. mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
  91. for (auto &k : mp[{a, b}]) {
  92. if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
  93. if (k.second.first == xx && k.second.second == yy) {
  94. ++ans;
  95. }
  96. }
  97. }
  98.  
  99. xx = -xx;
  100. alhpa2 = asin(yy / sqrt(sq));
  101. if (alhpa2 < alhpa) {
  102. alhpa2 += M_PI * 2;
  103. }
  104. mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
  105. for (auto &k : mp[{a, b}]) {
  106. if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
  107. if (k.second.first == xx && k.second.second == yy) {
  108. ++ans;
  109. }
  110. }
  111. }
  112.  
  113. yy = -yy;
  114. alhpa2 = asin(yy / sqrt(sq));
  115. if (alhpa2 < alhpa) {
  116. alhpa2 += M_PI * 2;
  117. }
  118. mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
  119. for (auto &k : mp[{a, b}]) {
  120. if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
  121. if (k.second.first == xx && k.second.second == yy) {
  122. ++ans;
  123. }
  124. }
  125. }
  126.  
  127. xx = -xx;
  128. alhpa2 = asin(yy / sqrt(sq));
  129. if (alhpa2 < alhpa) {
  130. alhpa2 += M_PI * 2;
  131. }
  132. mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
  133. for (auto &k : mp[{a, b}]) {
  134. if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
  135. if (k.second.first == xx && k.second.second == yy) {
  136. ++ans;
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. cout << ans << endl;
  145. }
  146.  
  147. re 0;
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement