标签:
题目大意:
分析:
AC code:
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef double DB;
typedef long double LD;
using namespace std;
const int MAXN = 75009;
const DB eps = 1e-9;
int n, A, B;
struct pot
{
DB x, y;
pot() {x = y = 0;}
pot(DB _x, DB _y):x(_x),y(_y){}
friend pot operator + (const pot &a, const pot &b) {return pot(a.x+b.x, a.y+b.y);}
friend pot operator - (const pot &a, const pot &b) {return pot(a.x-b.x, a.y-b.y);}
friend pot operator * (const pot &a, DB k) {return pot(a.x*k, a.y*k);}
friend pot operator / (const pot &a, DB k) {return pot(a.x/k, a.y/k);}
friend DB operator * (const pot &a, const pot &b) {return a.x*b.x+a.y*b.y;}
friend DB operator ^ (const pot &a, const pot &b) {return a.x*b.y-a.y*b.x;}
friend bool operator == (const pot &a, const pot &b) {return fabs(a.x-b.x) <= eps && fabs(a.y-b.y) <= eps;}
friend bool operator < (const pot &a, const pot &b)
{
if(fabs(a.x-b.x) <= eps) return a.y < b.y;
else return a.x < b.x;
}
DB size() {return sqrt(sqr(x)+sqr(y));}
}node[MAXN], o, t;
pot st[MAXN];
int top;
DB ans;
bool cross(const pot &a, const pot &b, const pot &c, const pot &d)
{
return ((c-a)^(b-a))*((d-a)^(b-a)) <= 0 && ((b-c)^(d-c))*((a-c)^(d-c)) <= 0;
}
pot get(const pot &a, const pot &b, const pot &c, const pot &d)
{
pot p = b-a, q = d-c, w = a-c;
DB k = (w^q)/(q^p);
return a+p*k;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
scanf("%d%d%d", &n, &A, &B);
o = pot(0, 0), t = pot(A, B);
for(int i = 1; i <= n; ++i)
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
node[i] = pot((DB)a/c, (DB)b/c);
ans = max(ans, min(A/node[i].x, B/node[i].y));
}
sort(node+1, node+n+1);
st[++top] = node[1], st[++top] = node[2];
for(int i = 3; i <= n; ++i)
{
if(node[i] == node[i-1]) continue;
while(top >= 2 && ((st[top]-node[i])^(st[top-1]-node[i])) < 0) top--;
st[++top] = node[i];
}
int j = top;
for(int i = n-1; i >= 1; --i)
{
if(node[i] == node[i-1]) continue;
while(top-1 >= j && ((st[top]-node[i])^(st[top-1]-node[i])) < 0) top--;
st[++top] = node[i];
}
st[0] = st[top];
for(int i = 0; i < top; ++i)
if(cross(st[i], st[i+1], o, t))
ans = max(ans, t.size()/get(st[i], st[i+1], o, t).size());
printf("%.6lf\n", ans);
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0;
}
标签:
原文地址:http://blog.csdn.net/qq_20118433/article/details/46592873