题目链接: 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. 同一台电脑管理多个SSH KEY

    同一台电脑关于多个SSH KEY管理 笔者之前为电脑中的homestead虚拟机配置过id_rsa,但现在因为想在github上搭建基于hexo的博客,所以需要配置github的ssh key,因此产 ...

  2. Java的同名属性、同名普通函数、同名静态函数,是否被覆盖

    作者按:虚拟函数的概念早就滚瓜烂熟了.但是今天面试发现:1.同名属性,2.同名普通函数,3.同名静态函数,是否被覆盖的问题.请看下面三个例子: 例子1:测试父类的属性是否存在和被完全覆盖class A ...

  3. jupyter与requests的初步使用

    upyter 是一个简易的,方便的写Python代码的工具包,requests是Python里非常好用的用来发送 http 请求的包. 开始学习本教程之前,请确保你已经安装了Python,并且安装了P ...

  4. Linux基础命令四

    iptables iptables -F:关闭防火墙 crontab -l查看定时任务 crontab -e :编辑定时任务 log日志相关: ls  /var/log:查看日志 du -sh  /v ...

  5. mac安装卸载brew

    1.安装 访问https://brew.sh,copy图中的命令到命令行中,进行下载安装 2.卸载 官方版本的卸载: /usr/bin/ruby -e "$(curl -fsSL https ...

  6. 前端开发HTML&css入门——CSS&选择器练习

    CSS 层叠样式表 (Cascading Style Sheets)css可以用来为网页创建样式表,通过样式表可以对网页进行装饰.所谓层叠,可以将整个网页想象成是一层一层的结构,层次高的将会覆盖层次低 ...

  7. Windows系统下安装MySQL详细教程(命令安装法)

    1.安装包下载. 下载地址:https://dev.mysql.com/downloads/mysql/ 点击下载之后,可以选择注册Oracle账号,也可以跳过直接下载. 下载完成后,选择一个磁盘内放 ...

  8. div的edit和drag(点击div可编辑、删除、拖动)

    1.可编辑: <div id="move" contentEditable="true">可编辑</div> 设置contentEdit ...

  9. Docker其他操作:查看内部细节、IP、删除容器

    1.查看容器内部细节 查看容器运行内部细节,比如可看容器的IP docker inspect mycentos2 2.查看容器IP地址 直接显示IP地址 docker inspect --format ...

  10. vue 之 双向绑定原理

    一.实现双向绑定 详细版: 前端MVVM实现双向数据绑定的做法大致有如下三种: 1.发布者-订阅者模式(backbone.js) 思路:使用自定义的data属性在HTML代码中指明绑定.所有绑定起来的 ...