这题的俩种方法都是看别人的代码,方法可以学习学习,要多看看。。

几何题用到向量。。

Points on Cycle

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

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
 
Source

//题意:一个以原点为中心的圆,告诉你圆上的一个点,求与另外的两个点组成的三角形的周长最长的两点作标。
//根据几何知识,知道圆内等边三角形的周长最长。所以题目转化为求已知一个点的圆内接等边三角形的另两点作标。
//思路:设P(x,y),一个方程是pow(x,2)+pow(y,2)=pow(r,2);另一个方程是根据向量知识,向量的夹角公式得到方程。
//因为圆心角夹角为120度,已知一个向量(即一个点作标),所以COS(2PI/3)=a*b/|a|*|b|;(a,b为向量);
//已知角和a向量,就可求b向量b(x,y).由方程组可求得(x,y);最后得到的是一元二次方程组,可得到两个解,即为两个点的作标。
//代码如下:
#include <stdio.h>
#include <math.h>
#define PI 3.1415926
int main()
{
double x,y,x1,y1,x2,y2,cosx,a,b,c,r,delta;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&x,&y);
r=sqrt(x*x+y*y);
a=r*r;
b=r*r*y;
c=r*r*r*r/4-x*x*r*r;
delta=b*b-4*a*c;
y1=(-1*b-sqrt(delta))/(2*a);
y2=(-1*b+sqrt(delta))/(2*a);
if(x==0)
{
x1=-sqrt(r*r-y1*y1);
x2=sqrt(r*r-y2*y2);
}
else
{
x1=(-1*r*r/2-y*y1)/x;
x2=(-1*r*r/2-y*y2)/x;
}
printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2);
}
return 0;
}
/*已知一个以(0,0)为圆心的圆和圆上的一点(x0,y0)求圆上的另外两点(x1,y1,)(x2,y2),使得向量(x1,y1)(x2,y2)和(x0,y0)各个向量两两之间夹角为120度
此题主要用到向量的叉乘和点乘列出两个二元一次方程组
1.
(x0,y0)X (x1,y1) = sin(120)*R^2 (r为圆的半径)
(x0,y0) * (x1,y1) = cos(120)*R^2
结果为:
x1=b*x0-a*y0; a=sin120
y1=b*y0+a*x0; b=cos120;
2.
(x0,y0)X (x2,y2) = -sin(120)*R^2 (r为圆的半径)
(x0,y0) * (x2,y2) = cos(120)*R^2
注:题目假设向量(x1,y1)在向量(x0,y0)逆时针方向 故叉乘结果为正值
(x2,y2)于(x0,y0)的顺时针方向 故叉乘结果为负值*/
#include <stdio.h>
#include <math.h>
int main()
{
double a,b,sinx,cosx,x0,y0,x1,y1,x2,y2;
int t;
a=sinx=sqrt(3.0)/2;
b=cosx=-0.5;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&x0,&y0);
x1=b*x0-a*y0;
y1=b*y0+a*x0;
x2=b*x0+a*y0;
y2=b*y0-a*x0;
if(y1<y2||((abs(y1-y2)<0.005)&&x1<x2))
{
printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2);
}
else
printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x1,y1);
}
return 0;
}

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 (几何 向量旋转)

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

  4. HDU 1700 Points on Cycle(向量旋转)

    题目链接 水题,卡了下下精度. #include <cstdio> #include <iostream> #include <cmath> using names ...

  5. hdu 1700 Points on Cycle 水几何

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

  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. 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)

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

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

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

随机推荐

  1. win7下 mysql主从配置实现

    win7下学习 mysql主从复制 一.环境: 主服务器(master):192.168.1.23 mysql版本:5.5 从服务器(slave):192.168.1.24 mysql版本:5.5   ...

  2. php 开启缓冲,页面纯静态化

    服务器默认不开启php缓冲区 两种方法开启 1.php.ini out_put_buffer = on 2.ob_start(); 页面纯静态化 file_put_contents()写文件 ob_s ...

  3. 使用vagrant作为开发环境后,js报错

    当你尝试修改一个js,并且用同样的方法更新之后,会遇到类似的问题,是的,就算重启VM上任何服务,甚至重启VM,依旧没有用,当然,比起其他资源文件,浏览器的反应会强烈一些,因为浏览器会提示未知错误,而你 ...

  4. (转载)Delphi TStringList的用法

    Delphi TStringList的用法 TStrings是一个抽象类,在实际开发中,是除了基本类型外,应用得最多的. TStringList 常用方法与属性: var List: TStringL ...

  5. Ms SQLServer中的Union和Union All的使用方法和区别

    Ms SQLServer中的Union和Union All的使用方法和区别 SQL UNION 操作符 UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的 ...

  6. hdu 2243 考研路茫茫——单词情结 ac自动机+矩阵快速幂

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2243 题意:给定N(1<= N < 6)个长度不超过5的词根,问长度不超过L(L <23 ...

  7. JAVA String 类

    java String类中的常用方法:public char charAt(int index)返回字符串中第index个字符:public int length()返回字符串的长度:public i ...

  8. mysql将多张表COUNT的数据相加

    由于数据量过大,我们将根据用户id 将数据存储在不同的表中,根据用户id模10的余数作为表的后缀.有如下十张表:test_0, test_1, ... ,test_9现在需要根据某个条件查询统计数据我 ...

  9. ASP.NET MVC got 405 error on HTTP DELETE request

    使用Backload的时候在本地调试通过,上传服务器后出现405错误(监控通信时可以发现ajax的返回结果为405) 通过修改webconfig可以解决: <system.webServer&g ...

  10. delphi xe5 android iny绿色版+最新SDK/NDK安装方法

    转自: http://bbs.2ccc.com/topic.asp?topicid=438595 首先感谢iny的绿色版,因为我的精简Win7 32位安装原版镜像4.63G过程正常,但是编译出错,后来 ...