fork download
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define int long long
  7. #define nn "\n"
  8. #define pi pair<int, int>
  9. #define fi first
  10. #define se second
  11. #define lb lower_bound
  12. #define ub upper_bound
  13. #define eb emplace_back
  14. #define pb push_back
  15. #define TASK "CTAMGIACV"
  16.  
  17. #define ms(a, x) memset(a, x, sizeof(a))
  18. #define all(a) a.begin(), a.end()
  19. #define All(a, n) a + 1, a + 1 + n
  20.  
  21. #define LOG 19
  22.  
  23. const int INF = 1e18;
  24. const int mod = 1e9;
  25. const int N = 1e5 + 5;
  26. const int MOD = 998244353;
  27. int n;
  28. pi p[505];
  29.  
  30. void nhap(){
  31. cin >> n;
  32. for(int i = 1; i <= n; i++){
  33. cin >> p[i].fi >> p[i].se;
  34. }
  35. }
  36.  
  37. void solve(){
  38. int ans = 0;
  39. for(int i = 1; i <= n; i++){
  40. for(int j = i + 1; j <= n; j++){
  41. for(int k = j + 1; k <= n; k++){
  42. int x1 = p[j].fi - p[i].fi;
  43. int y1 = p[j].se - p[i].se;
  44. int x2 = p[k].fi - p[i].fi;
  45. int y2 = p[k].se - p[i].se;
  46. if(x1 * x2 + y1 * y2 == 0){
  47. ans++;
  48. continue;
  49. }
  50. x1 = p[i].fi - p[j].fi;
  51. y1 = p[i].se - p[j].se;
  52. x2 = p[k].fi - p[j].fi;
  53. y2 = p[k].se - p[j].se;
  54. if(x1 * x2 + y1 * y2 == 0){
  55. ans++;
  56. continue;
  57. }
  58. x1 = p[i].fi - p[k].fi;
  59. y1 = p[i].se - p[k].se;
  60. x2 = p[j].fi - p[k].fi;
  61. y2 = p[j].se - p[k].se;
  62. if(x1 * x2 + y1 * y2 == 0){
  63. ans++;
  64. }
  65. }
  66. }
  67. }
  68. cout << ans << nn;
  69. }
  70. signed main(){
  71. if(fopen(TASK".INP", "r")){
  72. freopen(TASK".INP", "r", stdin);
  73. freopen(TASK".OUT", "w", stdout);
  74. }
  75. ios_base::sync_with_stdio(0);
  76. cin.tie(0);
  77. cout.tie(0);
  78. nhap();
  79. solve();
  80. return (0 ^ 0);
  81. }
  82.  
Success #stdin #stdout 0s 5312KB
stdin
5
0 0
5 4
0 4
4 5
5 0
stdout
4