Skip to content

Instantly share code, notes, and snippets.

@yurahuna
Created November 2, 2016 15:26
Show Gist options
  • Save yurahuna/25724a11a3d6ae304a2ae92eed5f6596 to your computer and use it in GitHub Desktop.
Save yurahuna/25724a11a3d6ae304a2ae92eed5f6596 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
#define int long long // <-----!!!!!!!!!!!!!!!!!!!
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);
typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
// #define double long double
typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-6;
const double INF = 1e12;
const double PI = acos(-1);
P readP() {
double x, y;
cin >> x >> y;
return P(x, y);
}
// rot p around q by theta (counter-clockwise)
P rotP(P p, P q, double theta) {
p -= q;
double x = p.real(), y = p.imag();
p = P(x * cos(theta) - y * sin(theta), x * sin(theta) + y * cos(theta));
p += q;
return p;
}
P center(P p, P q) {
// P v = q - p;
// double theta = asin(abs(v) / 2);
// v *= (1 / abs(v));
// P u = rotP(v, p, theta);
// return p + u;
// P v = q - p;
// P h = v * P(0., 1.) / abs(v);
// return p + (v / 2.) + h;
P v = q - p;
P h = P(v.imag(), -v.real());
h /= abs(h);
h *= sqrt(1 - norm(v / 2.));
P c = p + (v / 2.) + h;
return c;
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int n;
while (cin >> n, n) {
vector<P> p(n);
rep(i, n) p[i] = readP();
int ans = 1;
rep(i, n) {
rep2(j, i + 1, n) {
if (i == j) continue;
if (norm(p[i] - p[j]) > 4. + EPS) continue;
rep(s, 2) {
P c = (s ? center(p[i], p[j]) : center(p[j], p[i]));
int cnt = 2;
rep(k, n) {
if (k == i || k == j) continue;
if (norm(p[k] - c) < 1. + EPS) {
cnt++;
}
}
ans = max(ans, cnt);
}
}
}
cout << ans << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment