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 ...
随机推荐
- angularjs 实现排序功能
实现公式:{{orderBy_expression | orderBy:expression:reverse}} Example <script> var app=angular.modu ...
- SSI指令教程
一:概述 SSI:服务器端嵌入或者叫服务器端包含,是Server Side Include的简写.SSI技术通过在文档中加入SSI指令,让服务器端在输出文档之前解析SSI指令,并把解析完的结果和文档一 ...
- WSGI规格说明书
PEP 333 这应该是WSGI最权威的文档了 http://www.python.org/dev/peps/pep-3333/ 值翻译了最重要的前面部分,后面读者可以参考 当然文档有些生硬,欢迎 ...
- 转:使用 Docker 搭建 Java Web 运行环境
原文来自于:http://www.codeceo.com/article/docker-java-web-runtime.html Docker 是 2014 年最为火爆的技术之一,几乎所有的程序员都 ...
- Hibernate 框架的配置之一
1. 下载hibernate distribution 3.6.* final包 2. 解压zip包 3. 将lib目录下jpa和required目录下的jar包都拷贝到自己工程的WEB-INF目录下 ...
- 【技术贴】解决前台js传参中文乱码
方法1: 前台两次编码,后台一次解码.因为getParamet已经自动解了一次了. JavaScript: window.self.location="list.jsp?searchtext ...
- 【Java】理解 UDDI 注册中心的 WSDL
如何发布和查找 WSDL 服务描述 Web 服务描述语言(WSDL)有多种用法.特别是,根据应用程序的需要,WSDL 在 UDDI 注册中心有好几种使用方法.在这第 1 篇文章中(本系列共三篇),我们 ...
- mouseenter 和 mouseleave
做一个下拉菜单的时候,HTML结构如下: <ul> <li class="red"> <a href="">第一级</ ...
- 怎样在delphi中实现控件和窗体的拖拽
下面这2种方法都能实现对控件和窗体的拖拽 方法1 procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift ...
- Java NIO API详解
在JDK 1.4以前,Java的IO操作集中在java.io这个包中,是基于流的同步(blocking)API.对于大多数应用来说,这样的API使用很方便,然而,一些对性能要求较高的应用,尤其是服务端 ...