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

Points on Cycle

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

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
 
 
-----------------------------------------------------------------------
坐标旋转公式:x1=x*cosα - y*sinα
                   y1=y*cosα + x*sinα
 其中,x,y表示物体相对旋转点旋转角度α之前的坐标;x1,y1表示物体旋转α角后相对于旋转点的坐标
具体证明去找书吧
 
还有,圆周率pi要开到3.14159265才可以
 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#define eps 0.0005
#define pi 3.14159265
int main()
{
int n,m,i,j;
scanf("%d",&n);
while(n--)
{
double x1,y1,x2,y2,x3,y3;
double Q1=pi*/,Q2=pi*/;
scanf("%lf%lf",&x1,&y1);
x2=x1*cos(Q1)-y1*sin(Q1);
y2=y1*cos(Q1)+x1*sin(Q1);
x3=x1*cos(Q2)-y1*sin(Q2);
y3=y1*cos(Q2)+x1*sin(Q2);//printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
if(fabs(y2-y3)<eps)
{
if((x2-x3)>eps)
printf("%.3lf %.3lf %.3lf %.3lf\n",x3,y3,x2,y2);
else
{
printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
}
}
else if((y2-y3)>eps)
printf("%.3lf %.3lf %.3lf %.3lf\n",x3,y3,x2,y2);
else
printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x3,y3);
}
return ;
}
 

任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转a角度后的新的坐标设为(x0, y0),有公式:

x0= (x - rx0)*cos(a) - (y - ry0)*sin(a) + rx0 ;

y0= (x - rx0)*sin(a) + (y - ry0)*cos(a) + ry0 ;

hdu 1700 Points on Cycle(坐标旋转)的更多相关文章

  1. HDU 1700 Points on Cycle (坐标旋转)

    题目链接:HDU 1700 Problem Description There is a cycle with its center on the origin. Now give you a poi ...

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

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

  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 水几何

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

  5. hdu1700 Points on Cycle

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

  6. Points on Cycle (hdu1700,几何)

    Points on Cycle Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

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

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

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

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

  9. HDU-1700 Points on Cycle

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

随机推荐

  1. 【转】ubuntu64,ndk-r9 编译 ffmpeg 2.1.1的config文件

    #!/bin/bash NDK_ROOT=/home/wjh/fox/android-ndk-r9c/ PREBUILT=${NDK_ROOT}toolchains/arm-linux-android ...

  2. JavaWeb开发实例---Servlet

    1.页面转发:form表单的action属性值为Servlet类再web.xml中配置的URL. 2.重定向:sendRedirect()  只是 简单的页面跳转 转发:request.getRequ ...

  3. linux设备驱动归纳总结(二):模块的相关基础概念【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-59415.html linux设备驱动归纳总结(二):模块的相关基础概念 系统平台:Ubuntu 10 ...

  4. 161027、Java 中的 12 大要素及其他因素

    对于许多人来说,"原生云"和"应用程序的12要素"是同义词.本文的目的是说有很多的原生云只坚持了最初的12个因素.在大多数情况下,Java 能胜任这一任务.在本 ...

  5. 装多系统删除某个系统后,如何恢复ubuntu引导

    在重装系统或者再装多个系统后可能会出现ubuntu的引导文件不存在的情况,windows系列的引导文件可以用winpe修复,但是ubuntu就不可以,虽然网上很多种修复ubuntu的引导文件 方式,但 ...

  6. 【转载】Perl异常处理方法总结

    程序脚本在运行过程中,总会碰到这样那样的问题,我们会预知一些问题并为其准备好处理代码,而有一些不能预知.好的程序要能尽可能多的处理可能出现的异常问题,本文就总结了一些方法来解决这些异常,当然perl在 ...

  7. DECODE函数

    DECODE函数相当于一条件语句(IF),它将输入数值与函数中的参数列表相比较,根据输入值返回一个对应值.函数的参数列表是由若干数值及其对应结果值组成的若干序偶形式.当然,如果未能与任何一个实参序偶匹 ...

  8. CodeIgniter配置之config

    配置说明 $config['language']:指定项目语言包.需要注意的时Codeigniter自带的类库错误提示语言包位于/system/language/english/目录下,当这里配置非e ...

  9. HDU 1728:逃离迷宫(BFS)

    http://acm.hdu.edu.cn/showproblem.php?pid=1728 逃离迷宫 Problem Description   给定一个m × n (m行, n列)的迷宫,迷宫中有 ...

  10. 基本包装类型:Boolean、Number 和String

    /* var box = 'Mr. Lee'; //基本类型 //alert(box); //alert(typeof box); alert(box.substring(2)); //对象.方法(参 ...