题目链接: http://codeforces.com/problemset/gymProblem/100942/A

------------------------------------------------------------------------------------

我们可以把给定的角看成圆周角 从而算出圆心角

然后每条边以及一个角可以确定两个可能的圆

如果$M1\ M2$确定出来的两个圆与$M2\ M3$确定出来的两个圆圆心不同的话

再判断这两个圆的交点即为答案 另外每次两个交点中一定有一个点是$M2$

如果圆心相同就是四点共圆了

此题卡精度比较严重 不要随意地使用三角函数库函数 尤其是$atan2$这类的

 #include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1e-, inf = 1e8, pi = acos(-1.0);
const double eps2 = 1e-;
struct point
{
double x, y;
point(){}
point(double _x,double _y)
{
x = _x;
y = _y;
}
point operator - (const point &p) const
{
return point(x - p.x, y - p.y);
}
point operator + (const point &p) const
{
return point(x + p.x, y + p.y);
}
double operator * (const point &p) const
{
return x * p.y - y * p.x;
}
double operator / (const point &p) const
{
return x * p.x + y * p.y;
}
}a[];
struct circle
{
double x, y, r;
}c[];
int t, cnt;
double ang1, ang2;
bool flag;
double getdist2(const point &aa)
{
return (aa.x * aa.x + aa.y * aa.y);
}
double mycos(double B, double C, double A)
{
return (B * B + C * C - A * A) / (B * C * );
}
double mycos2(const point &aa, const point &bb, const point &cc)
{
double C2 = getdist2(aa - bb), A2 = getdist2(bb - cc), B2 = getdist2(cc - aa);
return (B2 + C2 - A2) / (sqrt(B2 * C2) * );
}
point rotate(const point &p, double cost, double sint)
{
double x = p.x, y = p.y;
return point(x * cost - y * sint, x * sint + y * cost);
}
void getcircle(const point &aa, const point &bb, double ang)
{
ang = (ang < pi * 0.5 ? ang: pi - ang);
point mid;
mid.x = (aa.x + bb.x) * 0.5;
mid.y = (aa.y + bb.y) * 0.5;
if(ang + eps < pi * 0.5)
{
double tan1 = tan(ang);
c[cnt].x = mid.x + (aa.y - mid.y) / tan1;
c[cnt].y = mid.y - (aa.x - mid.x) / tan1;
c[cnt].r = sqrt(getdist2(mid - point(c[cnt].x, c[cnt].y)) +
getdist2(mid - aa));
++cnt;
c[cnt].x = mid.x - (aa.y - mid.y) / tan1;
c[cnt].y = mid.y + (aa.x - mid.x) / tan1;
c[cnt].r = c[cnt - ].r;
++cnt;
}
else
{
c[cnt].x = mid.x;
c[cnt].y = mid.y;
c[cnt].r = sqrt(getdist2(mid - aa));
++cnt;
c[cnt] = c[cnt - ];
++cnt;
}
}
bool checkpoint(const point &re)
{
for(int i = ; i < ; ++i)
if(getdist2(a[i] -re) < eps)
return ;
double tmp = acos(mycos2(re, a[], a[])) - ang1 - pi;
while(tmp < -eps2)
tmp += pi;
if(abs(tmp) > eps2)
return ;
tmp = acos(mycos2(re, a[], a[])) - ang2 - pi;
while(tmp < -eps2)
tmp += pi;
return abs(tmp) < eps2;
}
void getpoint2(const circle &c1)
{
double dab = sqrt(getdist2(point(a[].x - a[].x, a[].y - a[].y)));
double ang = acos(dab / (c1.r * ));
ang -= ang1;
double len = c1.r * * cos(ang);
double cang1 = cos(ang1);
double l2 = len * cang1;
point d, re;
d.x = a[].x + (a[].x - a[].x) * l2 / dab;
d.y = a[].y + (a[].y - a[].y) * l2 / dab;
double l3 = len * sqrt( - cang1 * cang1);
re.x = d.x + (a[].y - a[].y) * l3 / dab;
re.y = d.y - (a[].x - a[].x) * l3 / dab;
if(checkpoint(re))
{
printf("%.8f %.8f\n", re.x, re.y);
flag = ;
return;
}
re.x = d.x - (a[].y - a[].y) * l3 / dab;
re.y = d.y + (a[].x - a[].x) * l3 / dab;
if(checkpoint(re))
{
printf("%.8f %.8f\n", re.x, re.y);
flag = ;
return;
}
}
void getpoint(circle c1, circle c2)
{
double dab = sqrt(getdist2(point(c1.x, c1.y) - point(c2.x, c2.y)));
if(dab < eps)
{
getpoint2(c1);
return;
}
if(c1.r > c2.r)
swap(c1, c2);
double cost = mycos(c1.r, dab, c2.r);
double sint = sqrt( - cost * cost);
point re = rotate(point(c2.x, c2.y) - point(c1.x, c1.y), cost, sint);
re.x = c1.x + re.x * (c1.r / dab);
re.y = c1.y + re.y * (c1.r / dab);
if(getdist2(a[] - re) < eps)
{
re = rotate(point(c2.x, c2.y) - point(c1.x, c1.y), cost, -sint);
re.x = c1.x + re.x * (c1.r / dab);
re.y = c1.y + re.y * (c1.r / dab);
}
if(!checkpoint(re))
return;
flag = ;
printf("%.8f %.8f\n", re.x, re.y);
}
int main()
{
scanf("%d", &t);
while(t--)
{
for(int i = ; i < ; ++i)
scanf("%lf%lf", &a[i].x, &a[i].y);
scanf("%lf%lf", &ang1, &ang2);
ang1 = ang1 * pi / ;
ang2 = ang2 * pi / ;
cnt = ;
getcircle(a[], a[], ang1);
getcircle(a[], a[], ang2);
flag = ;
getpoint(c[], c[]);
if(!flag)
getpoint(c[], c[]);
if(!flag)
getpoint(c[], c[]);
if(!flag)
getpoint(c[], c[]);
}
return ;
}

Gym 100942A Three seamarks的更多相关文章

  1. ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力

     Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS     Memory Limit:65536KB     64bit IO Fo ...

  2. ACM: Gym 101047K Training with Phuket's larvae - 思维题

     Gym 101047K Training with Phuket's larvae Time Limit:2000MS     Memory Limit:65536KB     64bit IO F ...

  3. ACM: Gym 101047E Escape from Ayutthaya - BFS

    Gym 101047E Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I6 ...

  4. ACM: Gym 101047B Renzo and the palindromic decoration - 手速题

     Gym 101047B  Renzo and the palindromic decoration Time Limit:2000MS     Memory Limit:65536KB     64 ...

  5. Gym 101102J---Divisible Numbers(反推技巧题)

    题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...

  6. Gym 100917J---Judgement(01背包+bitset)

    题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...

  7. Gym 100917J---dir -C(RMQ--ST)

    题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...

  8. Gym 101102D---Rectangles(单调栈)

    题目链接 http://codeforces.com/gym/101102/problem/D problem  description Given an R×C grid with each cel ...

  9. Gym 101102C---Bored Judge(区间最大值)

    题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...

随机推荐

  1. linux查找进程id和杀死进程以及查看内存??

    ps 命令用于查看当前正在运行的进程 ps ax : 显示当前系统进程的列表 ps aux : 显示当前系统进程详细列表以及进程用户 -e 显示所有进程,环境变量 此参数的效果和指定"A&q ...

  2. Consul服务发现在windows下简单使用

    目录 基本介绍: 服务连接: 客户端: 系列章节: 回到顶部 基本介绍: 安装: 下载地址:https://www.consul.io/downloads.html 运行: consul agent ...

  3. RNN, LSTM, GRU cells

    项目需要,先简记cell,有时间再写具体改进原因 RNN cell LSTM cell: GRU cell: reference: 1.https://towardsdatascience.com/a ...

  4. pL/Sql插入语句时报错,对表空间没有权限 对表空间 'USERS' 无权限

    进入dba为其授予权限:sqlplus sys/admin as sysdba; 为用户授予权限即可 grant unlimited tablespace to username;

  5. 使用Cookie记住登录用户

    在登录表单中,写入: 记住我: <select name="cookie">       <option value="0" selected ...

  6. ie10兼容问题 -- 将div定位absolute在图片img上面,导致div点击事件无效

    ie10兼容问题: 将div定位absolute在图片img上面,发现div若不加背景色,导致div点击事件(任何事件)无效. <div class="paper-box"& ...

  7. 007-cobbler+koan自动化重装系统

    一.操作步骤 1.在使用cobbler自动化安装的虚拟机上做以下操作 2.安装epel源(先配置好yum) [root@localhost ~]# yum install epel-release - ...

  8. [每日一学]apache camel|BDD方式开发apache camel|Groovy|Spock

    开发apache camel应用,最好的方式就是tdd,因为camel的每个组件都是相互独立并可测试的. 现在有很多好的测试框架,用groovy的Spock框架的BDD(行为测试驱动)是比较优秀和好用 ...

  9. ThreadLocal 解决simpledateformat线程不安全

    SimpleDateFormat在多线程情况下会出现线程不安全的情况,故用ThreadLoacl 处理/** * 用ThreadLocal处理simplDateFormat线程不安全 */public ...

  10. windows javaee 安装

    一. 下载jdk 并安装 二. 配置环境变量 JAVA_HOME:D:\Java\jdk1..0_25 CLASSPATH :.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt. ...