Advertisement
TheKabeton

Untitled

Nov 15th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.42 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;
  75. if (x == 0) {
  76. if (y > 0) {
  77. alhpa = M_PI / 2;
  78. } else {
  79. alhpa = M_PI + M_PI / 2;
  80. }
  81. } else {
  82. alhpa = atan(y / x);
  83. }
  84. mp[{x, y}].push_back({alhpa, {a, b}});
  85. for (auto &k : mp[{a, b}]) {
  86. if (k.second.first == x && k.second.second == y && k.first < 0.000000001) {
  87. ++ans;
  88. }
  89. }
  90. for (ll j = 0; j * j <= sq; ++j) {
  91. ll k = sq - j * j;
  92. auto sk = sqrt(k);
  93. if (abs(k - (ll)(sk + 0.000000001)) < 0.000000001) {
  94. ll xx = j, yy = (ll)(sk + 0.000000001);
  95. long double alhpa2;
  96. if (x == 0) {
  97. if (y > 0) {
  98. alhpa2 = M_PI / 2;
  99. } else {
  100. alhpa2 = M_PI + M_PI / 2;
  101. }
  102. } else {
  103. alhpa2 = atan(yy / xx);
  104. }
  105. if (alhpa2 < alhpa) {
  106. alhpa2 += M_PI * 2;
  107. }
  108. mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
  109. for (auto &k : mp[{a, b}]) {
  110. if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
  111. if (k.second.first == xx && k.second.second == yy) {
  112. ++ans;
  113. }
  114. }
  115. }
  116.  
  117. xx = -xx;
  118. if (x == 0) {
  119. if (y > 0) {
  120. alhpa2 = M_PI / 2;
  121. } else {
  122. alhpa2 = M_PI + M_PI / 2;
  123. }
  124. } else {
  125. alhpa2 = atan(yy / xx);
  126. }
  127. if (alhpa2 < alhpa) {
  128. alhpa2 += M_PI * 2;
  129. }
  130. mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
  131. for (auto &k : mp[{a, b}]) {
  132. if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
  133. if (k.second.first == xx && k.second.second == yy) {
  134. ++ans;
  135. }
  136. }
  137. }
  138.  
  139. yy = -yy;
  140. if (x == 0) {
  141. if (y > 0) {
  142. alhpa2 = M_PI / 2;
  143. } else {
  144. alhpa2 = M_PI + M_PI / 2;
  145. }
  146. } else {
  147. alhpa2 = atan(yy / xx);
  148. }
  149. if (alhpa2 < alhpa) {
  150. alhpa2 += M_PI * 2;
  151. }
  152. mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
  153. for (auto &k : mp[{a, b}]) {
  154. if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
  155. if (k.second.first == xx && k.second.second == yy) {
  156. ++ans;
  157. }
  158. }
  159. }
  160.  
  161. xx = -xx;
  162. if (x == 0) {
  163. if (y > 0) {
  164. alhpa2 = M_PI / 2;
  165. } else {
  166. alhpa2 = M_PI + M_PI / 2;
  167. }
  168. } else {
  169. alhpa2 = atan(yy / xx);
  170. }
  171. if (alhpa2 < alhpa) {
  172. alhpa2 += M_PI * 2;
  173. }
  174. mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
  175. for (auto &k : mp[{a, b}]) {
  176. if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
  177. if (k.second.first == xx && k.second.second == yy) {
  178. ++ans;
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. cout << ans << endl;
  187. }
  188.  
  189. re 0;
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement