Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. //#include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <queue>
  6. #include <fstream>
  7. #include <algorithm>
  8. #include <set>
  9. #include <cmath>
  10. #include <iomanip>
  11. using namespace std;
  12. int main()
  13. {
  14. ifstream fin;
  15. ofstream fout;
  16. fin.open("input.txt");
  17. fout.open("output.txt");
  18. int n;
  19. double x = 0, y = 0;
  20. fin >> n;
  21. vector <vector <int> > check(n, vector<int>(n, 0));
  22. vector <pair <double, double> > a(n);
  23. vector <pair <double, double> > pos;
  24. for (int i = 0; i < n; i++)
  25. fin >> a[i].first >> a[i].second;
  26. for (int i = 0; i < n; i++)
  27. {
  28. for (int j = i + 2; j < n; j++)
  29. {
  30. if (check[i][j] == 2)
  31. continue;
  32. check[i][j] = 2;
  33. check[j][i] = 2;
  34. double A1 = a[i].second - a[j].second;
  35. double B1 = a[j].first - a[i].first;
  36. double C1 = a[i].first*a[j].second - a[i].second*a[j].first;
  37. for (int k = i+1; k < n; k++)
  38. {
  39. if (k == j || k == i)
  40. continue;
  41. for (int l = k + 2; l < n; l++)
  42. {
  43. if (l == j || l == i)
  44. continue;
  45. double A2 = a[k].second - a[l].second;
  46. double B2 = a[l].first - a[k].first;
  47. double C2 = a[k].first*a[l].second - a[k].second*a[l].first;
  48. if (A1*B2 == A2*B1)
  49. continue;
  50. x = (C2*B1 - C1*B2) / (A1*B2 - A2*B1);
  51. y = (A2*C1 - A1*C2) / (A1*B2 - A2*B1);
  52. pos.push_back(make_pair(x, y));
  53. }
  54. }
  55. }
  56. }
  57. int c = 1;
  58. for (int i = 0; i < pos.size(); i++)
  59. {
  60. int tpr = 0;
  61. for (int j = 0; j < pos.size(); j++)
  62. {
  63. if (i == j)
  64. continue;
  65. if (pos[i].first == pos[j].first && pos[i].second == pos[j].second)
  66. {
  67. tpr++;
  68. if (tpr > c)
  69. {
  70. c = tpr;
  71. x = pos[i].first;
  72. y = pos[i].second;
  73. }
  74. }
  75. }
  76. }
  77. int p = 0;
  78. c++;
  79. fout << c << endl;
  80. fout << setprecision(8) << fixed << x;
  81. fout << ' ';
  82. fout << fixed << setprecision(8) << y;
  83. //system("pause");
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement