HDU 1700 Points on Cycle (几何 向量旋转)
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 (几何 向量旋转)的更多相关文章
- hdu 1700 Points on Cycle(坐标旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...
- HDU 1700 Points on Cycle (坐标旋转)
题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...
- HDU 1700 Points on Cycle(向量旋转)
题目链接 水题,卡了下下精度. #include <cstdio> #include <iostream> #include <cmath> using names ...
- hdu 1700 Points on Cycle 水几何
已知圆心(0,0)圆周上的一点,求圆周上另外两点使得三点构成等边三角形. 懒得推公式,直接用模板2圆(r1=dist,r2=sqrt(3)*dist)相交水过 #include<cstdio&g ...
- 简单几何(向量旋转+凸包+多边形面积) UVA 10652 Board Wrapping
题目传送门 题意:告诉若干个矩形的信息,问他们在凸多边形中所占的面积比例 分析:训练指南P272,矩形面积长*宽,只要计算出所有的点,用凸包后再求多边形面积.已知矩形的中心,向量在原点参考点再旋转,角 ...
- Points on Cycle (hdu1700,几何)
Points on Cycle Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu1700 Points on Cycle
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...
- Points on cycle
Description There is a cycle with its center on the origin. Now give you a point on the cycle, you a ...
- HDU-1700 Points on Cycle
这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others) ...
随机推荐
- sencha touch + Cordova 3.x下载文件
今天实现了一个文件下载功能,在网上找了下资料发现有些问题. 我用的是小米1s,安卓 4.1.2,cordova 3.5,打包测试运行正常 首先在控制层launch方法中加入以下代码: // 等待加载P ...
- getconf
用途 将系统配置变量值写入标准输出. 语法 getconf [ -v specification ] [ SystemwideConfiguration | PathConfiguration Pat ...
- ThinkPHP-5.0.23新的RCE漏洞测试和POC
TP5新RCE漏洞 昨天又是周五,讨厌周五曝漏洞,还得又得加班,算了,还是先验证一波.新的TP5RCE,据说发现者因为上次的RCE,于是又审计了代码,结果发现的.TP5也成了万人轮啊. 测试 环境搭建 ...
- dhroid - eventbus 事件总线
你听过onClick 事件,onItemClick 事件,事件总线不一定听过吧, eventbus 事件总线也是一个编程思想,为什么要设计EventBus了,因为他是领域驱动设计中比不可少的模块,它承 ...
- thinkCMF----自定义配置调用
有些时候,需要在后台给网站一些其他的配置: 这个配置,一般都是通过修改代码实现的,ThinkCMF本身没有这个配置: 找到site.html 增加一个Group就可以: 在配置里面做相应的配置就可以:
- 170821、本地代码上传gitlub
第一步:建立git仓库 cd到你的本地项目根目录下,执行git命令 git init #初始化项目 第二步:将项目的所有文件添加到仓库中 git add . 或者git add -A #如果想添加某个 ...
- POJ_2533_Longest Ordered Subsequence
Longest Ordered Subsequence Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 55490 Acc ...
- android adt自带eclipse无法设置ndk路径
android sdk官网下载r23版本的adt时自带的eclipse没有设置ndk路径的地方,通过Install New Software 发现无法更新,那么如何解决这个问题呢? 软件百度云 ...
- RuntimeError: Object: Could not open SDE workspace
客户环境,linux 终端里,使用arcpy.ListUsers() 报错:RuntimeError: Object: Could not open SDE workspace 经检查,问题在于 该机 ...
- Django - 补充目录
Django项目部署 importlib应用 - django contenttypes - django组件 Django - Model操作 Django - 用户认证.用户组.用户权限 Djan ...