Points on Cycle

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1303    Accepted Submission(s): 459

Problem Description

There is a cycle with its center on the origin. 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.

Input
 
There are T test cases, in each case there are 2 decimal number representing the coordinate of the given point.
 
Output
 
For each testcase you are supposed to output the coordinates of both of the unknow points by 3 decimal places of precision
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.

NOTE

when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.

 
Sample Input
2
1.500 2.000
563.585 1.251
 
Sample Output
0.982 -2.299 -2.482 0.299
-280.709 -488.704 -282.876 487.453
 
题意:(摘自网络)一个以原点为中心的圆,告诉你圆上的一个点,求与另外的两个点组成的三角形的周长最长的两点作标。
根据几何知识,知道圆内等边三角形的周长最长。所以题目转化为求已知一个点的圆内接等边三角形的另两点作标。  
思路:设P(x,y),一个方程是x*x+y*y=r*r;另一个方程是根据向量知识,向量的夹角公式得到方程。
因为圆心角夹角为120度,已知一个向量(即一个点作标),所以夹角公式:COS(2PI/3)=a*b/|a|*|b|;(a,b为向量);
已知角和a向量,就可求b向量b(x,y).由方程组可求得(x,y);最后得到的是一元二次方程组,可得到两个解,即为两个点的作标。

  下面是我自己的所作的详解:

                
 

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

#include<stdio.h>
#include<math.h>
int main()
{
double x1,x2,x3,y1,y2,y3,a,b,c,r;
int T;
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf",&x1,&y1);
r=sqrt(x1*x1+y1*y1);
a=;
b=y1;
c=r*r/-x1*x1;
y2=(-b-sqrt(b*b-*a*c))/(*a);
y3=(-b+sqrt(b*b-*a*c))/(*a);
if(fabs(x1-)<1e-)//注意这里不能是x1==0
{
x2=-sqrt(r*r-y2*y2);
x3=sqrt(r*r-y3*y3);
}
else
{
x2=(-r*r/-y1*y2)/x1;
x3=(-r*r/-y1*y3)/x1;
}
printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3); }
return ;
}

我自己错了好几次的,,,,囧rz    写的这么认真,这么详细了,真的很辛苦,


代码如下:

Points on Cycle (hdu1700,几何)的更多相关文章

  1. hdu 1700 Points on Cycle 水几何

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

  2. HDU 1700 Points on Cycle (几何 向量旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ...

  3. HDU-1700 Points on Cycle

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

  4. 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)

                                                Points on Cycle Time Limit:1000MS     Memory Limit:32768 ...

  5. hdu1700 Points on Cycle

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

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

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

  7. L - Points on Cycle(旋转公式)

    L - Points on Cycle Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  8. HDU1700:Points on Cycle

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

  9. hdu1700 Points on Cycle (数学)

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

随机推荐

  1. MVC所有的ActionResult

    一.所有的Controller都继承自System.Web.Mvc.Controller 目前ASP.NET MVC3默认提供了多种ActionResult的实现,在System.Web.Mvc命名空 ...

  2. Lerning Entity Framework 6 ------ Inserting, Querying, Updating, and Deleting Data

    Creating Entities First of all, Let's create some entities to have a test. Create a project Add foll ...

  3. hash的安全性

    在区块链中,我们面临着两个问题: 隐私问题 快速对账问题 由于区块链中,每个人都存在着一个账本,当一个人有收入的时候,将会进行广播到所有人的账本,例如张三收入xxx钱,这样子所有的账本才能同步更新.但 ...

  4. [学习笔记]K-D Tree

    以前其实学过的但是不会拍扁重构--所以这几天学了一下 \(K-D\ Tree\) 的正确打开姿势. \(K\) 维 \(K-D\ Tree\) 的单次操作最坏时间复杂度为 \(O(k\times n^ ...

  5. canvas制作完美适配分享海报

    基于mpvue实现的1080*1900小程序海报 html   <canvas class="canvas" :style="'width:'+windowWidt ...

  6. Spring Boot日志管理

    SpringBoot内部使用Commons Logging来记录日志,但是默认也提供了对常用日志组件的支持,如:Log4j,Logback等.每种Logger都可以通过配置使用控制台或者文件输出日志内 ...

  7. SQL高效查询两个表不同的数据

    逻辑相对复杂,但是速度最快: )

  8. 怎么把excel表格内的数据导入数据库?

    第一种方法: 思路:想要把excel表格内的数据直接导入数据库不是那么容易,可以把excel表格另存为.csv格式的文档(特点:内容以逗号分割):然后通过一系列的文档操作函数处理成为一个二维数组,然后 ...

  9. Yarn 资源调度框架

    Yarn 资源调度框架    实现对资源的细粒度封装(cpu,内存,带宽)    此外,还可以通过yarn协调多种不同计算框架(MR,Spark)    概述        Apache Hadoop ...

  10. 矩阵乘法在numpy/matlab/数学上的不同

    数学意义上的矩阵乘法 注意事项: 1.当矩阵A的列数(column)等于矩阵B的行数(row)时,A与B可以相乘. 2.矩阵C的行数等于矩阵A的行数,C的列数等于B的列数. 3.乘积C的第m行第n列的 ...