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. C陷阱与缺陷读书笔记

    2.1理解函数声明 这一章仔细分析了(*(void(*)())0)();这条语句的含义,并且提到了typedef的一种函数指针类型定义的用法. 我们经常用到的typedef用法是用于指定结构体的类型, ...

  2. 解决Win7启动时出现“windows未能启动。原因可能是最近更改了硬件或软件”的问题

    昨天公司终于大发慈悲,统一更换电脑配置,终于要摆脱“手扶拖拉机”的时代了,赶上“动车时代”了.不过不想换硬盘,因为重新要安装太多东西,环境配置一大堆,所以就硬盘没有换,不过当我开机启动的时候,悲剧发生 ...

  3. 遍历json数组实现树

    今天小颖在工作中遇到要遍历树得问题了,实现后,怕后期遇到又忘记啦,所以记录下嘻嘻,其实这个和小颖之前写过得一篇文章    json的那些事    中第4点有关json的面试题有些类似. 数组格式: v ...

  4. vue.js - 解决vue-cli打包后自动压缩代码

    一.webpack中引入的压缩代码 /build/webpack.prod.conf.js const OptimizeCSSPlugin = require('optimize-css-assets ...

  5. 兵器簿之cocoaPods的安装和使用

    以前添加第三方库的时候总是直接去Github下载然后引入,但是如果这些第三方库发生了更新,我们还需要手动去更新项目,所以现在引入之前一直想弄都一直没有弄的cocoaPods,现在演示一把过程 其实非常 ...

  6. Mongodb 副本集 数据同步简单测试

    副本集的搭建,请见  CENTOS6.5 虚拟机MONGODB创建副本集 接下来将简单说明下副本集之间的数据同步. 1.首先,进入primary节点 MOGO_PATH/bin/mongo  -por ...

  7. pandas将DataFrame的列变成行索引

    pandas提供了set_index方法可以将DataFrame的列(多列)变成行索引,通过reset_index方法可以将层次化索引的级别会被转移到列里面. 1.DataFrame的set_inde ...

  8. arcpy调试

    arcpy调试过程中, 在代码中加入一些输出语句来判断代码运行流程, 使用  arcpy.AddMessage(“”)    而不要使用 print    如下两图所示,print并未输出~~

  9. Vagrant入门一(转)

    原文: https://github.com/astaxie/Go-best-practice/blob/master/ebook/zh/01.2.md 1.2 Vagrant安装配置 实际上Vagr ...

  10. 通过PyPI镜像安装Python包

    有时,我们直接用pip install package_name安装包时,下载很慢,我们可以尝试从PyPI镜像下载包. 这里是镜像列表和目前的状态: http://www.pypi-mirrors.o ...