zoukankan      html  css  js  c++  java
  • L

    L - Points on Cycle

    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

    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
     
     
    //题目意思,在一个圆心在原点的圆上,给你一个点的坐标,求圆内接正三角形的另两个点坐标
     
    //这周做题真的很蛋疼,什么都一次过不了,什么奇奇怪怪的错误都有。
    这题用旋转公式,弧度传4*pi/3 ,竟然是错的,必须传-2*pi/3,真是不懂,好烦!!!
     
     
     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <math.h>
     4 using namespace std;
     5 
     6 const double pi=3.141592654;
     7 
     8 int main()
     9 {
    10     int t;
    11     scanf("%d",&t);
    12     double x,y;
    13     double x1,y1,x2,y2;
    14     while (t--)
    15     {
    16         scanf("%lf%lf",&x,&y);
    17         x1=x*cos(2*pi/3)-y*sin(2*pi/3);
    18         y1=x*sin(2*pi/3)+y*cos(2*pi/3);
    19         x2=x*cos(-2*pi/3)-y*sin(-2*pi/3);
    20         y2=x*sin(-2*pi/3)+y*cos(-2*pi/3);
    21 
    22         if (y1<y2||(y1==y2&&x1<x2))//题目要求,y值小的在前面,y一样x小的在前面
    23             printf("%.3lf %.3lf %.3lf %.3lf
    ",x1,y1,x2,y2);
    24         else
    25             printf("%.3lf %.3lf %.3lf %.3lf
    ",x2,y2,x1,y1);
    26     }
    27     return 0;
    28 }
    View Code

     

     

     
     
     
     
     
  • 相关阅读:
    SQLDataSet中执行DDL语句
    在SQL语句中使用参数
    delphi排序算法
    ClientDataSet中的PacketRecords属性,减轻网络负载,提升服务器与客户端性能
    ClientDataSet中修改,删除,添加数据和Delta属性
    SQLMonitor观察DBE的执行行为
    this的指向(慢慢添加)
    如何在Html的CSS中去除<li>标签前面小黑点,和ul、LI部分属性方法
    AJAX的工作原理及其优缺点
    IE浏览器和Firefox浏览器兼容性问题及解决办法
  • 原文地址:https://www.cnblogs.com/haoabcd2010/p/5692214.html
Copyright © 2011-2022 走看看