Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int NaN = 1e9+13; // not a number;
- const int N = 1e5;
- template<typename T>
- T sqr(T &a)
- {
- return a*a;
- }
- struct point{
- double x, y, z;
- void input();
- void print();
- double line();
- };
- void point::input(){
- cin >> x >> y >> z;
- }
- void point::print(){
- cout << x << ' ' << y << ' ' << z << endl;
- }
- double point::line(){
- return sqr(x) + sqr(y) + sqr(z);
- }
- bool check(point a, point b, double R){
- point c = {a.x - b.x, a.y - b.y, a.z - b.z};
- if (c.line() <= R * R * R)
- return true;
- else
- return false;
- }
- point a[N];
- int main(){
- int n;
- cin >> n;
- double R;
- cin >> R;
- for(int i = 0; i < n; ++i)
- a[i].input();
- int cnt = 0;
- point ans = {NaN, NaN, NaN};
- int ans_cnt = NaN;
- for(int i = 0; i < n; ++i)
- {
- for(int j = 0; j < n; ++j)
- {
- if (check(a[i], a[j], R))
- cnt++;
- }
- if (cnt < ans_cnt)
- {
- ans_cnt = cnt;
- ans = a[i];
- }
- }
- ans.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement