Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #define pb push_back
  3.  
  4. #include <iostream>
  5. #include <climits>
  6. #include <algorithm>
  7. #include <iomanip>
  8. #include <cmath>
  9. #include <vector>
  10. #include <map>
  11. #include <string>
  12. #include <stack>
  13. #include <set>
  14. #include <cstdio>
  15. #include <cctype>
  16. #include <queue>
  17. #include <bitset>
  18. #include <functional>
  19. #include <cassert>
  20. #include <unordered_map>
  21.  
  22. using namespace std;
  23.  
  24. #define int long long
  25.  
  26. typedef long long ll;
  27. typedef unsigned long long ull;
  28. typedef pair<ll, ll> pll;
  29. typedef pair<int, int> pii;
  30. typedef long double ld;
  31. typedef double db;
  32.  
  33. const ll N = 5e5 + 20;
  34. const ll INF = LLONG_MAX;
  35.  
  36.  
  37. int gcd(int a, int b) {
  38. if (b == 0) return a;
  39. return gcd(b, a % b);
  40. }
  41.  
  42.  
  43. signed main() {
  44. #ifndef ONLINE_JUDGE
  45. freopen("input.txt", "r", stdin);
  46. //freopen("output.txt", "w", stdout);
  47. #else
  48. #endif
  49. ios_base::sync_with_stdio(0);
  50. cin.tie(0); cout.tie(0);
  51.  
  52. int n;
  53. cin >> n;
  54. vector<pii> a(n);
  55. map<int, map<pii, int>> cnt;
  56. for (int i = 0; i < n; ++i) {
  57. cin >> a[i].first >> a[i].second;
  58. }
  59. for (int i = 0; i < n; ++i) {
  60. for (int j = 0; j < n; ++j) {
  61. if (i == j) continue;
  62. int a1 = a[i].first - a[j].first;
  63. int b1 = a[i].second - a[j].second;
  64. int g = gcd(abs(a1),abs(b1));
  65. a1 /= g;
  66. b1 /= g;
  67. if (a1 < 0) {
  68. a1 *= -1;
  69. b1 *= -1;
  70. }
  71. cnt[i][{a1, b1}]++;
  72. //cnt[i][{-a1, -b1}]++;
  73. }
  74. }
  75. int ans = 0;
  76.  
  77. for (int i = 0; i < n; ++i) {
  78. for (int j = 0; j < n; ++j) {
  79. if (i == j) continue;
  80. int a1 = a[i].first - a[j].first;
  81. int b1 = a[j].second - a[i].second;
  82. int g = gcd(abs(a1), abs(b1));
  83. a1 /= g;
  84. b1 /= g;
  85. if (a1 < 0) {
  86. a1 *= -1;
  87. b1 *= -1;
  88. }
  89. ans += cnt[j][{-b1, a1}];
  90. ans += cnt[j][{b1, -a1}];
  91. }
  92. }
  93. cout << ans << endl;
  94. return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement