Dang_Quan_10_Tin

Kingdom of Cats

Nov 15th, 2020
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #define task ""
  4. using namespace std;
  5. using ll = long long;
  6. using ld = long double;
  7.  
  8. const int N = 50 + 2;
  9. int n;
  10. struct Point
  11. {
  12.     ll x, y;
  13.     Point operator-(const Point &a)
  14.     {
  15.         Point ans;
  16.         ans.x = x - a.x;
  17.         ans.y = y - a.y;
  18.         return ans;
  19.     }
  20.     ll operator*(const Point &a)
  21.     {
  22.         return x * a.y - y * a.x;
  23.     }
  24. } a[N];
  25.  
  26. void Read()
  27. {
  28.     for (int i = 1; i <= n; ++i)
  29.         cin >> a[i].x >> a[i].y;
  30. }
  31.  
  32. ll Online(int i, int j, int t)
  33. {
  34.     return (a[i] - a[j]) * (a[i] - a[t]) == 0ll;
  35. }
  36.  
  37. void Solve()
  38. {
  39.     if (n < 4)
  40.     {
  41.         cout << "0\n";
  42.         return;
  43.     }
  44.     ll ans = 0;
  45.     for (int i = 1; i <= n; ++i)
  46.         for (int j = i + 1; j <= n; ++j)
  47.             for (int t = j + 1; t <= n; ++t)
  48.                 for (int h = t + 1; h <= n; ++h)
  49.                     if (!Online(i, j, t) && !Online(i, t, h) && !Online(j, t, h) && !Online(i, j, h))
  50.                         ++ans;
  51.     cout << ans << "\n";
  52. }
  53.  
  54. int32_t main()
  55. {
  56.     ios_base::sync_with_stdio(0);
  57.     cin.tie(0);
  58.     cout.tie(0);
  59.     if (fopen(task ".INP", "r"))
  60.     {
  61.         freopen(task ".INP", "r", stdin);
  62.         freopen(task ".OUT", "w", stdout);
  63.     }
  64.     while (cin >> n)
  65.     {
  66.         if (n == 0)
  67.             break;
  68.         Read();
  69.         Solve();
  70.     }
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment