Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-------------------- Code written by Kabeton --------------------*/
- /*--- Contacts: https://vk.com/kabeton and TheKabeton@yandex.ru ---*/
- #define _USE_MATH_DEFINES
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <cstdlib>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- #include <map>
- #include <unordered_map>
- #include <set>
- #include <bitset>
- #include <tuple>
- #include <queue>
- #include <stack>
- #include <valarray>
- #include <sstream>
- #include <cstring>
- #include <numeric>
- #include <ctime>
- #include <cassert>
- using namespace std;
- #define endl "\n"
- #define re return
- #define fi first
- #define se second
- #define all(a) a.begin(), a.end()
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef pair<ll, ll> pll;
- typedef vector<ll> vll;
- typedef vector<vll> vvll;
- typedef vector<pll> vpll;
- typedef vector<vpll> vvpll;
- const ll mod = 1e9 + 7;
- const ll inf = 1e15;
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- ll t;
- cin >> t;
- for (ll i = 0; i < t; ++i) {
- ll ans = 0;
- ll n;
- cin >> n;
- map<pair<ll, ll>, vector<pair<long double, pair<ll, ll>>>> mp;
- ll x, y, a, b;
- for (ll q = 0; q < n; ++q) {
- cin >> x >> y >> a >> b;
- if (x == 0 && y == 0) {
- mp[{0, 0}].push_back({-1, {a, b}});
- for (auto &k : mp[{a, b}]) {
- if (k.second.first == 0 && k.second.second == 0) {
- ++ans;
- }
- }
- } else {
- ll sq = x * x + y * y;
- long double alhpa;
- if (x == 0) {
- if (y > 0) {
- alhpa = M_PI / 2;
- } else {
- alhpa = M_PI + M_PI / 2;
- }
- } else {
- alhpa = atan(y / x);
- }
- mp[{x, y}].push_back({alhpa, {a, b}});
- for (auto &k : mp[{a, b}]) {
- if (k.second.first == x && k.second.second == y && k.first < 0.000000001) {
- ++ans;
- }
- }
- for (ll j = 0; j * j <= sq; ++j) {
- ll k = sq - j * j;
- auto sk = sqrt(k);
- if (abs(k - (ll)(sk + 0.000000001)) < 0.000000001) {
- ll xx = j, yy = (ll)(sk + 0.000000001);
- long double alhpa2;
- if (x == 0) {
- if (y > 0) {
- alhpa2 = M_PI / 2;
- } else {
- alhpa2 = M_PI + M_PI / 2;
- }
- } else {
- alhpa2 = atan(yy / xx);
- }
- if (alhpa2 < alhpa) {
- alhpa2 += M_PI * 2;
- }
- mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
- for (auto &k : mp[{a, b}]) {
- if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
- if (k.second.first == xx && k.second.second == yy) {
- ++ans;
- }
- }
- }
- xx = -xx;
- if (x == 0) {
- if (y > 0) {
- alhpa2 = M_PI / 2;
- } else {
- alhpa2 = M_PI + M_PI / 2;
- }
- } else {
- alhpa2 = atan(yy / xx);
- }
- if (alhpa2 < alhpa) {
- alhpa2 += M_PI * 2;
- }
- mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
- for (auto &k : mp[{a, b}]) {
- if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
- if (k.second.first == xx && k.second.second == yy) {
- ++ans;
- }
- }
- }
- yy = -yy;
- if (x == 0) {
- if (y > 0) {
- alhpa2 = M_PI / 2;
- } else {
- alhpa2 = M_PI + M_PI / 2;
- }
- } else {
- alhpa2 = atan(yy / xx);
- }
- if (alhpa2 < alhpa) {
- alhpa2 += M_PI * 2;
- }
- mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
- for (auto &k : mp[{a, b}]) {
- if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
- if (k.second.first == xx && k.second.second == yy) {
- ++ans;
- }
- }
- }
- xx = -xx;
- if (x == 0) {
- if (y > 0) {
- alhpa2 = M_PI / 2;
- } else {
- alhpa2 = M_PI + M_PI / 2;
- }
- } else {
- alhpa2 = atan(yy / xx);
- }
- if (alhpa2 < alhpa) {
- alhpa2 += M_PI * 2;
- }
- mp[{xx, yy}].push_back({alhpa2 - alhpa, {a, b}});
- for (auto &k : mp[{a, b}]) {
- if (abs(alhpa2 - alhpa - k.first) < 0.0000000001) {
- if (k.second.first == xx && k.second.second == yy) {
- ++ans;
- }
- }
- }
- }
- }
- }
- }
- cout << ans << endl;
- }
- re 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement