http://acm.hdu.edu.cn/showproblem.php?pid=1700

题目大意:

  二维平面,一个圆的圆心在原点上。给定圆上的一点A,求另外两点B,C,B、C在圆上,并且三角形ABC的周长是最长的。

解题思路:

  我记得小学的时候给出个一个定理,在园里面正多边形的的周长是最长的,这个定理我不会证明。

所以这里是三角形,当三角形为正三角形的时候,周长是最长的。

因为圆心在原点,所以我就向量(x,y)绕原点逆时针旋转120度和顺时针旋转120度。给定的点A可以看成(x,y)向量。

  向量旋转是有公式的(算法竞赛入门经典 训练指南 P256)。

AC代码:

 #include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std; const double PI = acos(-1.0); struct Point{
double x, y; Point(double x = , double y = ): x(x), y(y){} void scan(){
scanf("%lf%lf", &x, &y);
} void print(){
printf("%.3lf %.3lf", x, y);
} bool operator < (const Point &other){
return y < other.y || (y == other.y && x < other.x);
}
}; typedef Point Vector; Vector rotate(Vector A, double rad){//向量旋转公式
return Vector(A.x * cos(rad) - A.y * sin(rad), A.y * cos(rad) + A.x * sin(rad));
} int main(){
int t;
Point p[];
scanf("%d", &t);
while(t--){
p[].scan(); p[] = rotate(p[], PI * / );//逆时针旋转120度
p[] = rotate(p[], -PI * / );//顺时针旋转120度 if(p[] < p[]) swap(p[], p[]);//按题目要求输出 p[].print(); putchar(' ');
p[].print(); putchar('\n');
}
return ;
}

HDU 1700 Points on Cycle (几何 向量旋转)的更多相关文章

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

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

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

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

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

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

  4. hdu 1700 Points on Cycle 水几何

    已知圆心(0,0)圆周上的一点,求圆周上另外两点使得三点构成等边三角形. 懒得推公式,直接用模板2圆(r1=dist,r2=sqrt(3)*dist)相交水过 #include<cstdio&g ...

  5. 简单几何(向量旋转+凸包+多边形面积) UVA 10652 Board Wrapping

    题目传送门 题意:告诉若干个矩形的信息,问他们在凸多边形中所占的面积比例 分析:训练指南P272,矩形面积长*宽,只要计算出所有的点,用凸包后再求多边形面积.已知矩形的中心,向量在原点参考点再旋转,角 ...

  6. Points on Cycle (hdu1700,几何)

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

  7. hdu1700 Points on Cycle

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

  8. Points on cycle

    Description There is a cycle with its center on the origin. Now give you a point on the cycle, you a ...

  9. HDU-1700 Points on Cycle

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

随机推荐

  1. 题目1008:最短路径问题(最短路径问题dijkstra算法)

    题目链接:http://ac.jobdu.com/problem.php?pid=1008 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

  2. yum配置与使用(很详细)

    yum的配置一般有两种方式,一种是直接配置/etc目录下的yum.conf文件,另外一种是在/etc/yum.repos.d目录下增加.repo文件.一.yum的配置文件 $ cat /etc/yum ...

  3. linux mint 安装 SecureCRT

    最喜欢的ssh工具莫过于SecureCRT了,功能强大,方便易用.最近安装了mint17.1(基于ubuntu),就想安装一个SecureCRT来使用. [此SecureCRT仅作测试使用,不做商业用 ...

  4. 简单ORM工具的设计和编写,自己项目中曾经用过的

    http://www.cnblogs.com/szp1118/archive/2011/03/30/ORM.html 在之前的一个项目中自己编写了一个简单的ORM小工具,这次重新整理和重构了一下代码, ...

  5. Thinkphp框架下设置session的过期时间

    打开项目中的配置文件,添加session的过期配置,如下: 'SESSION_OPTIONS' => array( 'name' => 'BJYSESSION', //设置session名 ...

  6. java不足前面补0

    // 0 代表前面补充0 // 3代表长度为3 // d 代表参数为正数型 result=String.format("%0"+3+"d",result);

  7. 高盛为什么认为中国AI领域将超越美国?

    不久前,高盛发布的名为<中国在人工智能领域崛起>的研究报告,报告中,高盛认为中国已经成为AI领域的主要竞争者,中国政府建设“智慧型经济”和“智慧社会”的目标将有可能推动中国未来GDP的增长 ...

  8. Java 中运用DOS运行class(字节码)

    附属: -dir:例举该目录的所有文件名称 有<dir>是文件夹,没有<dir>是文件-cd: 改变目录 进入其他目录 change direction-cd\:一次性回到根目 ...

  9. This version of the rendering library is more recent than your version of ADT plug-in. Please update ADT plug-in

    地址:http://stackoverflow.com/questions/18852983/eclipse-reports-rendering-library-more-recent-than-ad ...

  10. Cross-origin resource sharing JSON with Padding 同源策略 JSONP 为什么form表单提交没有跨域问题,但ajax提交有跨域问题? XMLHttpRequest and the Fetch API follow the same-origin policy 预检请求(preflight request)

    https://zh.wikipedia.org/wiki/跨来源资源共享 跨来源资源共享(CORS)是一份浏览器技术的规范,提供了 Web 服务从不同域传来沙盒脚本的方法,以避开浏览器的同源策略[1 ...