No older revisions available
No older revisions available
~cpp
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
struct Cookies {
double x;
double y;
int numCookies;
};
vector<Cookies> cookies;
void input(double x, double y)
{
Cookies cooki;
cooki.x = x;
cooki.y = y;
cooki.numCookies = 0;
cookies.push_back(cooki);
}
void process()
{
double d;
int i,j;
for(i = 0; i<cookies.size()-1; i++) {
for(j = i+1; j<cookies.size(); j++) {
d = sqrt(pow(cookies[i].x - cookies[j].x, 2) + pow(cookies[i].y - cookies[j].y , 2));
if(d <= 5.0) {
cookies[i].numCookies++;
cookies[j].numCookies++;
}
}
}
int max_num = 0;
for(i=0; i<cookies.size(); i++) {
if(cookies[i].numCookies > max_num)
max_num = cookies[i].numCookies;
}
cout << max_num <<endl;
cookies.clear();
}
int main()
{
double x, y;
int testCase;
cin >> testCase;
while(testCase>0) {
cout << endl;
while(true)
{
cin.ignore();
if(cin.peek() == '\n')
break;
else
cin >> x >> y;
input(x,y);
}
process();
testCase--;
}
return 0;
}