UESTC814 - Justice is Given by Light

电科校赛

计算几何 + 两次二分

eps为1e-10 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define MOD ((int)(1e9) + 7)
#define eps 1e-10
using namespace std;
typedef long long ll;
int dcmp(double x) {
  if(fabs(x) < eps) return 0; else return x < 0 ? -1 : 1;
}
double sqr(double x) {
    return x*x;
}
struct Point {
  double x, y;
  Point(double x=0, double y=0):x(x),y(y) { }
  void print() {
    printf("(%.3lf, %.3lf)", x, y);
  }
};
Point operator + (Point A, Point B) { return Point(A.x+B.x, A.y+B.y); }
Point operator - (Point A, Point B) { return Point(A.x-B.x, A.y-B.y); }
Point operator * (Point A, double p) { return Point(A.x*p, A.y*p); }
Point operator / (Point A, double p) { return Point(A.x/p, A.y/p); }

bool operator < (const Point& a, const Point& b) {
  return a.x < b.x || (a.x == b.x && a.y < b.y);
}

bool operator == (const Point& a, const Point &b) {
  return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}

double Dot(Point A, Point B) { return A.x*B.x + A.y*B.y; }
double Length(Point A) { return sqrt(Dot(A, A)); }
double Cross(Point A, Point B) { return A.x*B.y - A.y*B.x; }

struct Line {
  Point p;    // 直线上任意一点
  Point v;   // 方向向量
  double ang; // 极角,即从x正半轴旋转到向量v所需要的角(弧度)
  Line() {}
  Line(Point P, Point v): p(P),v(v){ ang = atan2(v.y, v.x); }
  Point point(double a) {
        return p+(v*a);
  }
  bool operator < (const Line& L) const {
    return ang < L.ang;
  }
  void print() {
    p.print(), cout << " "; point(1).print(); cout << endl;
  }
};

Point p[25], a, b;
Line l[25];
int N, cnt;

struct Circle
{
    Point c;
    double r;
    Circle(){}
    Circle(Point c, double r):c(c), r(r){}
    Point point(double a) //根据圆心角求点坐标
    {
        return Point(c.x+cos(a)*r, c.y+sin(a)*r);
    }
};

bool InCircle(Point x, Circle c) { return dcmp(c.r - Length(c.c - x)) >= 0;}
bool judge(Point l, Point r, Circle cl, Circle cr) {
    Point mid;
    while( dcmp(Length(l-r)) > 0 ) {
        mid = (l + r) * 0.5;
        if (InCircle(mid, cl) && InCircle(mid, cr)) return true;
        if (InCircle(mid, cl)) l = mid;
        else r = mid;
    }
    return false;
}
bool check(double M) {
    Circle ca(a,M), cb(b,M);
    for (int i = 0; i < cnt; ++ i) {
        if ( (InCircle(l[i].p,ca) && InCircle(l[i].point(1),ca)) || (InCircle(l[i].p,cb) && InCircle(l[i].point(1),cb)) ) continue;
        if ( InCircle(l[i].p,ca) && InCircle(l[i].point(1),cb) ) {
            if (judge(l[i].p, l[i].point(1), ca, cb)) continue;
        }
        if ( InCircle(l[i].p,cb) && InCircle(l[i].point(1),ca) ) {
            if (judge(l[i].p, l[i].point(1), cb, ca)) continue;
        }
        return false;
    }
    return true;
}
int main() {
    while (scanf("%d", &N) != EOF) {
        for (int i = 0; i < N; ++ i) {
            scanf("%lf%lf", &p[i].x, &p[i].y);
        }
        scanf("%lf%lf", &a.x, &a.y);
        scanf("%lf%lf", &b.x, &b.y);
        l[0].p = p[N-1]; l[0].v = p[0] - p[N-1];
        cnt = 1;
        for (int i = 0; i < N-1; ++ i) {
            l[cnt].p = p[i], l[cnt].v = p[i+1] - p[i];
            cnt ++;
        }
        double R = 0.0;
        for (int i = 0; i < N; ++ i) {
            R = max(R, Length(p[i]-a));
        }
        double L = 0.0, M;
        while (R - L > eps) {
            M = (L + R) * 0.5;
            if (!check(M)) L = M;
            else R = M;
        }
        printf("%.3f\n", M);
    }
}


互联网络程序设计是指在互联网上进行程序开发和设计的过程。UESTC则是我国的一所著名高校——电子科技大学。 互联网络程序设计 uestc包含了两个主要的方面:互联网络和程序设计。互联网络是指将多个计算机网络通过通信链路互相连接起来,实现信息共享和资源共享的网络系统。程序设计是指根据需求和目标,通过编写代码和设计算法,实现计算机程序的过程。 互联网络程序设计 uestc的学习内容主要包括以下几个方面: 1. 网络知识:学习互联网络的基本概念、原理和协议,如TCP/IP协议、HTTP协议等。掌握网络编程的基本技术,能够编写网络应用程序。 2. 数据通信:学习数据通信的基本原理和技术,包括数据传输的方式、数据压缩和加密等。了解网络安全和数据保护的基本知识。 3. 程序设计:学习编程语言和开发工具,如Java、C++和Python等。掌握常用的编程技巧和方法,能够设计和实现复杂的网络应用程序。 4. Web开发:学习Web开发的基本知识和技术,包括HTML、CSS、JavaScript等。能够设计和实现交互式的Web应用程序。 5. 数据库技术:学习数据库的基本原理和技术,如SQL语言和数据库管理系统。能够设计和管理数据库,实现数据的存储和检索。 通过学习互联网络程序设计 uestc,可以掌握互联网应用开发的基本技能,具备设计和实现网络应用程序的能力。这对于目前互联网行业的人才需求来说是非常重要的,也为学生提供了广阔的就业和创业机会。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值