Gym 100942A Three seamarks
题目链接: 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的更多相关文章
- 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 ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
随机推荐
- Python入门之 函数
Python入门之 函数 1.初识函数 1.1 什么是函数? <1> 将某个功能封装到一个空间中就是一个函数 <2> 减少重复代码 1.2 定义函数 def -- python ...
- HNUSTOJ-1437 无题
1437: 无题 时间限制: 1 Sec 内存限制: 128 MB提交: 268 解决: 45[提交][状态][讨论版] 题目描述 tc在玩一个很无聊的游戏:每一次电脑都会给一个长度不超过10^5 ...
- Cypher 语句实战
Cypher 语句实战 下载和安装 Neo4j windows 桌面版- 环境设置 https://www.w3cschool.cn/neo4j/neo4j_exe_environment_setup ...
- 执行npm publish 报错:401 Unauthorized - PUT https://registry.npmjs.org/kunmomotest - You must be logged in to publish packages.
前言 执行npm publish 报错:401 Unauthorized - PUT https://registry.npmjs.org/kunmomotest - You must be logg ...
- 用eclipse怎么打war包?
用eclipse怎么打war包? 在服务器上部署很多都是用war包进行部署的,eclipse是很友好的支持把java项目打成war包的,下面就把打war的经验写出来,供大家参考 百度经验:jingya ...
- SpringMVC设置不拦截静态资源css,js
转自:https://blog.csdn.net/sh513023410/article/details/81361867
- Python 操作sqlite数据库及保存查询numpy类型数据(一)
# -*- coding: utf-8 -*- ''' Created on 2019年3月6日 @author: Administrator ''' import sqlite3 import nu ...
- 关于Windows 10上MarkdownPad2无法预览的解决办法
升级win10后,发现一直可以用的MarkdownPad2预览功能不可以用了.于是在网上搜索了一下,刚开始没有解决.不过现在可以了.现在把解决方案记录下来.Windows10上使用MarkdownPa ...
- 事件,IO,select
事件驱动模型 对于普通编程来说,代码遵循线性流程:开始-->代码A-->代码B-->代码C-->...-->结束,编程者知道代码的运行顺序,由编程者控制 事件驱动模型,流 ...
- PAT Advanced 1007 Maximum Subsequence Sum (25 分)
Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to ...