题目链接: 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. RabbitMq学习4-发布/订阅(Publish/Subscribe)

    一.发布/订阅 分发一个消息给多个消费者(consumers).这种模式被称为“发布/订阅”. 为了描述这种模式,我们将会构建一个简单的日志系统.它包括两个程序——第一个程序负责发送日志消息,第二个程 ...

  2. Netty入门搭建

    什么是Netty Netty 是一个基于 JAVA NIO 类库的异步通信框架,它的架构特点是:异步非阻塞.基于事件驱动.高性能.高可靠性和高可定制性. 为什么选择netty而不是使用NIO 1.使用 ...

  3. ajax使用jsonp跨域调用webservice error错误信息"readyState":4,"status":200,"statusText":"success"

    主要还是接口写有问题 至于ajax保持简洁写法即可 $.ajax({ dataType: 'jsonp', type: ‘get’, data: {}, url: '' })

  4. 看完阮一峰的React教程后, 我写了一个TodoList

    看完阮一峰的React教程后,就自己做了这个TodoList,自己慢慢琢磨效率差了点但是作为入门小练习还是不错的. 以下是效果图:我的源码:todolistUI:bootstrap 4 一.组件化 我 ...

  5. ubuntu14.04首次安装.md

    ubuntu14.04 安装后的工作 1.换软件源 sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup 网易163更新服务器(广东广州 ...

  6. FPGA异步时钟系统中信号处理之单比特信号

    有些东西当你习以为常而不去深思熟虑的时候,致命的错误就会因此埋下!      FPGA开发中难免会遇到跨时钟域处理的问题,而对于单比特信号,我会不假思索的回答:打两拍不久解决了吗?但是事实时,这佯作的 ...

  7. Thinkphp5 自定义分页样式显示页码和数量

    Thinkphp5 自带的分页比较简单,本文通过修改Bootstrap类自定义显示分页的页码和数量 一.修改完成后如下图显示 二.修改Bootstrap代码: 1.为了不改动Bootstrap.php ...

  8. Mongo --01 介绍、安装、优化报警

    目录 一 . NoSQL 介绍 二.MongoDB简介 三.MongoDB特点 四. mongo应用场景 五. 安装配置mongodb 六.优化报警 一 . NoSQL 介绍 NoSQL,指的是非关系 ...

  9. Tensorflow fintune

    https://zhuanlan.zhihu.com/p/42183653 tf2.0中有更简单的做法,和keras一样

  10. C# 实战笔记

    http://www.cnblogs.com/ymnets/p/3424514.html 学习点 关于IEnumerable和IQueryable两接口的区别 二者都是静态类 区另主要在: (1)所有 ...