已知圆心(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. wamp无法登录phpmyadmin问题

    文章来源:PHP座谈会 地址:http://bbs.phpthinking.com/forum.php? mod=viewthread&tid=163 第一步.用navicat确认一下,自己的 ...

  2. HTML5_文本元素

    <!DOCTYPE html> <hmtl> <html  lang="zh-en"> <head> <meta  chars ...

  3. 在用TabbarController中出现navigationController 嵌套报错

    假设出现: nested push animation can result in corrupted navigation bar Finishing up a navigation transit ...

  4. AndroidUI的组成部分ProgressBar

    package com.gc.progressbar; /* * 1.ProgressBar组件也是一组重要的组件,ProgressBar本身代表了进度条组件, * 它还派生了两个经常使用的组件:Se ...

  5. IOS使用Jenkins持续集成

    本文详细介绍了开发过程,提高效率进行IOS-Jenkins持续集成. 第二http://blog.csdn.net/monkey_cool/article/details/43270885 背景 平时 ...

  6. 使用Bootstrap 他写道网站

    新发现vdceye有些难看的网站,为了找到一个bootstrap工具,我一次又一次地写信给网站 这个工具是很容易使用 http://vdceye.com/ 版权声明:本文博客原创文章,博客,未经同意, ...

  7. 允许debian wheezy支持IOS7+的iphone.

    IOS更新, 连接到数据线,不能使用 我想复制iphone照片只能用于内itunes对?  于linux这里面其实很容易处理. 在这里,我们使用了一个相对较新的组件libimobiledevice 为 ...

  8. 将cocos2dx+lua创建的游戏port到windows phone

    在整个Port的过程中遇到的问题总结例如以下 1.一定要使用最新版本号的cocos2dx,原因大家看一下changelog就知道了,近期的cocos2dx版本号都是在修windows phone上的b ...

  9. Java网络编程注意事项3

    如何使用POST请求和GET请求Web网站发送请求,下面的参考代码: import java.io.BufferedReader; import java.io.InputStream; import ...

  10. x264 - open gop and closed gop

    GOP - Group of picture(影像集团),它指的是两个I帧之间的距离. Reference(基准期).  它指的是两个P帧之间的距离. 简而言之, 跨参考gop的,变open gop: ...