HDU1700:Points on Cycle
Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other
you may assume that the radius of the cycle will not exceed 1000.
Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X.
when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.
1.500 2.000
563.585 1.251
-280.709 -488.704 -282.876 487.453
题意:以原点为圆心,给出圆上的一点,要求两位两点,是的这三个点的距离和最大,很容易想到这是一个等边三角形,而事实上,经过对题目给出样例的测试也证明了这确实是一个等边三角形
思路:几何水题
我们可以得到方程组
x^2+y^2 = r^2
(a-x)^2+(b-y^2)=3r^2
解方程组得到的两点即为三角形的另外两点
#include <stdio.h>
#include <math.h> int main()
{
int t;
double x,y,x2,y2,r;
double ax,ay,bx,by,k,m,l,A,B,C;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&x,&y);
r = x*x+y*y;
A = r;
B = y*r;
C = r*r/4-r*x*x;
ay = (-B-sqrt(B*B-4*A*C))/(2*A);
by = (-B+sqrt(B*B-4*A*C))/(2*A);
if(fabs(x-0)<1e-7)//防止除数出现0的情况
{
ax=-sqrt(r-ay*ay);
bx=sqrt(r-by*by);
}
else
{
ax=(-r/2-ay*y)/x;//由于ay必定小于by,所以ax也必定小于bx,所以无需进行大小判定
bx=(-r/2-by*y)/x;
}
printf("%.3lf %.3lf %.3lf %.3lf\n",ax,ay,bx,by);
}
return 0;
}
HDU1700:Points on Cycle的更多相关文章
- hdu1700 Points on Cycle
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=1700 题目: Points on Cycle Time Limit: 1000/1000 MS ...
- HDU-1700 Points on Cycle
这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看.. 几何题用到向量.. Points on Cycle Time Limit: 1000/1000 MS (Java/Others) ...
- 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)
Points on Cycle Time Limit:1000MS Memory Limit:32768 ...
- Points on Cycle (hdu1700,几何)
Points on Cycle Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 1700 Points on Cycle(坐标旋转)
http://acm.hdu.edu.cn/showproblem.php?pid=1700 Points on Cycle Time Limit: 1000/1000 MS (Java/Others ...
- L - Points on Cycle(旋转公式)
L - Points on Cycle Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- hdu1700 Points on Cycle (数学)
Problem Description There is a cycle with its center on the origin. Now give you a point on the cycl ...
- 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 (坐标旋转)
题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...
随机推荐
- 【BZOJ2049】【LCT】Cave 洞穴勘测
Description 辉 辉热衷于洞穴勘测.某天,他按照地图来到了一片被标记为JSZX的洞穴群地区.经过初步勘测,辉辉发现这片区域由n个洞穴(分别编号为1到n)以及若干通 道组成,并且每条通道连接了 ...
- ASP.NET页面跳转的三种方法比较
在ASP.NET下,经常需要在页面之间跳转,下面我们来分别介绍一下关于.NET中Response.Redirect(),Sever.Execute(),Server.Transfer() 三种页面跳转 ...
- getJSON回调函数不执行问题?
利用getJSON异步请求时,回调函数不执行,不知道是什么问题? php 返回数据 header("Content-type:text/json"); echo json_enco ...
- openerp report image
webkit : 再mako 文件中插入以下代码, <% %>标签用于再mako中定义代码或者函数. 然后 ${ embed_image('图片类型', 图片字段 , 宽度,高度) } ...
- LCD驱动学习笔记
通过这几天的学习发现驱动的框架感觉都差不多,一般分为以下几个步骤: 分配一个结构体 struct x *x = amlloc(); 设置结构体的参数 硬件寄存器 file_operations 注册 ...
- UIDevice-b
typedef NS_ENUM(NSInteger, UIDeviceOrientation) //设备方向 { UIDeviceOrientationUnknown, UIDeviceOrienta ...
- 一篇旧文章,结合汇编探索this指针
//VC6.0下成功编译 #include <iostream.h> class X{ public: void foo(int b,int c){ this->a=b*c; cou ...
- 1、MyBatisNet的安装使用
用到的几个DLL按理说应该到官网下载,但这个官网是谷大哥的,不知道是不是被屏蔽,总打不开,幸好从别人的程序里拷过来一份,直接放在自己的程序里就行! 程序结构如下: Providers.config,S ...
- Node.js快速入门
Node.js是什么? Node.js是建立在谷歌Chrome的JavaScript引擎(V8引擎)的Web应用程序框架. 它的最新版本是:v0.12.7(在编写本教程时的版本).Node.js在官方 ...
- matlab取整
matlab取整 Matlab取整函数有: fix, floor, ceil, round.取整函数在编程时有很大用处.一.取整函数1.向零取整(截尾取整)fix-向零取整(Round towards ...