Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <vector>
- #include <queue>
- #include <fstream>
- #include <algorithm>
- #include <set>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main()
- {
- ifstream fin;
- ofstream fout;
- fin.open("input.txt");
- fout.open("output.txt");
- int n;
- double x = 0, y = 0;
- fin >> n;
- vector <vector <int> > check(n, vector<int>(n, 0));
- vector <pair <double, double> > a(n);
- vector <pair <double, double> > pos;
- for (int i = 0; i < n; i++)
- fin >> a[i].first >> a[i].second;
- for (int i = 0; i < n; i++)
- {
- for (int j = i + 2; j < n; j++)
- {
- if (check[i][j] == 2)
- continue;
- check[i][j] = 2;
- check[j][i] = 2;
- double A1 = a[i].second - a[j].second;
- double B1 = a[j].first - a[i].first;
- double C1 = a[i].first*a[j].second - a[i].second*a[j].first;
- for (int k = i+1; k < n; k++)
- {
- if (k == j || k == i)
- continue;
- for (int l = k + 2; l < n; l++)
- {
- if (l == j || l == i)
- continue;
- double A2 = a[k].second - a[l].second;
- double B2 = a[l].first - a[k].first;
- double C2 = a[k].first*a[l].second - a[k].second*a[l].first;
- if (A1*B2 == A2*B1)
- continue;
- x = (C2*B1 - C1*B2) / (A1*B2 - A2*B1);
- y = (A2*C1 - A1*C2) / (A1*B2 - A2*B1);
- pos.push_back(make_pair(x, y));
- }
- }
- }
- }
- int c = 1;
- for (int i = 0; i < pos.size(); i++)
- {
- int tpr = 0;
- for (int j = 0; j < pos.size(); j++)
- {
- if (i == j)
- continue;
- if (pos[i].first == pos[j].first && pos[i].second == pos[j].second)
- {
- tpr++;
- if (tpr > c)
- {
- c = tpr;
- x = pos[i].first;
- y = pos[i].second;
- }
- }
- }
- }
- int p = 0;
- c++;
- fout << c << endl;
- fout << setprecision(8) << fixed << x;
- fout << ' ';
- fout << fixed << setprecision(8) << y;
- //system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement