题目链接: 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. OpenGL字体绘制

    /* glfont.hpp sdragonx 2019-08-15 00:03:33 opengl字体类,提供初学者参考学习 opengl初始化之后,创建字体 font.init(L"微软雅 ...

  2. CentOS卸载lamp环境的步骤

    学习PHP的时候需要在CentOS系统下安装lamp环境,安装容易卸载就没那么简单了,因为lamp由Apache.MySQL.PHP三个部分构成,需要逐个卸载,小编就给大家介绍下CentOS卸载lam ...

  3. phpstorm配置成sublime的代码高亮逼格风格

    使用sublime text3的风格来编程感觉是相当逼格的,然而在php的时候还是觉得phpstorm用起来更顺手一点. 正好在phpstorm中也有配置sublime类似风格的插件,这里来教大家如何 ...

  4. xcode自动生成代码片段

    一.什么是代码片段 当在Xcode中输入dowhile并回车后,Xcode会出现下图所示的提示代码: 这就是代码片段,目的是使程序员以最快的速度输入常用的代码片段,提高编程效率.该功能是从Xcode4 ...

  5. man - 格式化并显示在线帮助手册页

    总览 man [-acdfFhkKtwW] [-m 系统名] [-p <前处理程序>] [-C <配置文件>] [-M <路径>] [-P <浏览方式> ...

  6. Python小技巧:使用*解包和itertools.product()求笛卡尔积(转)

    leetcode上做提示时候看到有高人用这个方法解题 [问题] 目前有一字符串s = "['a', 'b'],['c', 'd']",想把它分开成为两个列表: list1 = [' ...

  7. hdu 4633 Who's Aunt Zhang(polya+逆元)

    Who's Aunt Zhang Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. 创建kudu数据集测试总结

    参考文档: https://cloud.tencent.com/developer/article/1474797 https://www.tgshenghe.com/a77nr1/nzt9t1.ht ...

  9. 【hiho1044】状压dp1

    题目大意:给定一个长度为 N 的序列,每个位置有一个权值,现选出一些点,满足相邻的 M 个点中至多有 Q 个点被选择,求选出点权的最大值是多少. 题解:若没有相邻的限制,这道题类似于子集和问题,即:背 ...

  10. CodeMix使用教程:构建自定义DevStyle主题

    [MyEclipse CI 2019.4.0安装包下载] DevStyle主题允许开发人员自定义工作台,无论是喜欢带有明亮图标的浅色背景还是带有柔和色彩的神色背景,开发人员都可以将工作台调整到适合的色 ...