已知圆心(0,0)圆周上的一点,求圆周上另外两点使得三点构成等边三角形。

懒得推公式,直接用模板2圆(r1=dist,r2=sqrt(3)*dist)相交水过

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iterator>
using namespace std;
#define eps 1e-6
typedef long long ll;
inline double sqr(double x)
{
return x*x;
}
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
int sig(double x)
{
if(fabs(x)<eps) return 0;
if(x>0) return 1;
return -1;
}
struct point
{
double x,y;
point(){};
point(double a,double b):x(a),y(b){}
void input()
{
scanf("%lf%lf",&x,&y);
}
friend point operator + (const point &a,const point &b)
{
return point(a.x+b.x,a.y+b.y);
}
friend point operator - (const point &a,const point &b)
{
return point(a.x-b.x,a.y-b.y);
}
friend bool operator == (const point &a,const point &b)
{
return sig(a.x-b.x)==0 && sig(a.y-b.y)==0;
}
friend point operator * (const point &a,const double &b)
{
return point(a.x*b,a.y*b);
}
friend point operator * (const double &a,const point &b)
{
return point(a*b.x,a*b.y);
}
friend point operator / (const point &a,const double &b)
{
return point(a.x/b,a.y/b);
}
double norm()
{
return sqrt(sqr(x)+sqr(y));
}
}a,b;
double det(const point &a,const point &b)
{
return a.x*b.y-a.y*b.x;
} double dot(const point &a,const point &b)
{
return a.x*b.x+a.y*b.y;
}
double dist(const point &a,const point &b)
{
return (a-b).norm();
}
point rotate_point(const point &p,double A)
{
double tx=p.x,ty=p.y;
return point(tx*cos(A)-ty*sin(A),tx*sin(A)+ty*cos(A));
} 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);
}
pair<point,point> crosspoint(point ap,double ar,point bp,double br)
{
double d=(ap-bp).norm();
double cost=(ar*ar+d*d-br*br)/(2*ar*d);
double sint=sqrt(1.0-cost*cost);
point v=(bp-ap)/(bp-ap).norm()*ar;
return make_pair(ap+rotate(v,cost,-sint),ap+rotate(v,cost,sint));
}
int main()
{
int cas;b.x=0;b.y=0;
scanf("%d",&cas);
while(cas--)
{
a.input();
double r=dist(a,b);
pair<point,point> ans=crosspoint(b,r,a,sqrt(3.0)*r);
double x1=ans.first.x,y1=ans.first.y,x2=ans.second.x,y2=ans.second.y;
if(y1<y2||y1==y2&&x1<x2) printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2);
else printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x1,y1);
}
return 0;
}

hdu 1700 Points on Cycle 水几何的更多相关文章

  1. HDU 1700 Points on Cycle (几何 向量旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ...

  2. hdu 1700 Points on Cycle(坐标旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...

  3. HDU 1700 Points on Cycle (坐标旋转)

    题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...

  4. HDU 1700 Points on Cycle(向量旋转)

    题目链接 水题,卡了下下精度. #include <cstdio> #include <iostream> #include <cmath> using names ...

  5. Points on Cycle (hdu1700,几何)

    Points on Cycle Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. hdu1700 Points on Cycle

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...

  7. HDU-1700 Points on Cycle

    这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others)     ...

  8. 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)

                                                Points on Cycle Time Limit:1000MS     Memory Limit:32768 ...

  9. L - Points on Cycle(旋转公式)

    L - Points on Cycle Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

随机推荐

  1. [Windows Phone] 以多国语言做为开发前提 (2)

    原文:[Windows Phone] 以多国语言做为开发前提 (2) ? 前言 在先前的文章 [Windows Phone 开发 - 以多国语言做为开发前提 (1)] 中说明了简单的多国语言范例,今天 ...

  2. mybaits使用存储过程

    如何使用Mybaits调用数据库存储过程,按以下顺序Oracle案例库: 1.在数据库中创建以下存储过程: create or replace procedure pro_hello(p_result ...

  3. 乐在其中设计模式(C#) - 工厂方法模式(Factory Method Pattern)

    原文:乐在其中设计模式(C#) - 工厂方法模式(Factory Method Pattern) [索引页][源码下载] 乐在其中设计模式(C#) - 工厂方法模式(Factory Method Pa ...

  4. 妈蛋:kinMaxShow旋转木马异常,WebUploader图片上传坑爹,图像被压缩

    今天晚上在改造轮播图. 原来的代码是这种: <div> <img src="${static}/image/index/banner/`.jpg" /> & ...

  5. Mysql 5.6 新特性

    随笔,真的随笔,以后理解得更深了再修改.   Index Condition Pushdown 更多的让存储引擎去处理Where语句中的条款,避免返回无关字段数据等:   Multi-Range Re ...

  6. 兔子--Spring基金会

    设计模式的基本目的: 对象之间的解耦.使用容器来管理组件.减少不同组件之间的耦合 控制返回,搜索请求委托给容器 将积极考虑被动接受 版权声明:本文博主原创文章,博客,未经同意不得转载.

  7. 【转】window.scroll 浏览器滚动条的参数总结

    如内容超出单元格,则隐藏style="TABLE-LAYOUT: fixed" 让弹出窗口总是在最上面: <body onblur="this.focus();&q ...

  8. mysql常见操作汇总

    1.Mysql服务突然启不来了,报错: 在分析时发现MySQL Server 5.0\data下面有个名称为用户名,扩展名为.err的文件: 150725 20:01:19 [Note] 自己的安装目 ...

  9. VS2012 安装出错 :通道正在关闭

    从微软官网下的安装包iso,解压后安装时总是出现 3个错误,提示什么管道正在关闭,看了很多解决办法,挑了一个简单的:安装包有问题,重新下载一个,就好了(持续更新....)

  10. MVC简单的认识

    学习一个新知识,首先要了解的就是以下几个问题,它是什么?它能干什么?使用它有什么优点?这篇文章就环绕这几个问题来展开讨论. mvc不是一种编程语言,严格来说.它都不算是一门技术.它是开发软件时使用的一 ...