Sdut 2603:rescue the Princess__others

Source: Internet
Author: User
Tags pow
Rescue the Princess Time limit:1000ms Memory limit:65536k have questions. Dot here ^_^ Topic Description

Several days ago, a beast caught a beautiful princess and the princess were put in prison. To rescue the princess, a prince who wanted to marry the princess set out immediately. Yet, the beast set a maze. Only if the Prince find out the maze ' s exit can he save the princess.

    Now, here comes the problem. The maze is a dimensional plane. The beast is smart, and he hidden the princess snugly. He marked two coordinates of An equilateral triangle in the maze. The two marked coordinates are A (x1,y1) and B (X2,y2). The third coordinate C (X3,Y3) is the maze ' s exit. If the Prince can find out the exit, he can save the princess. After the prince comes to the maze, he finds out the "A" (x1,y1) and B (X2,y2), but he doesn ' t know where the C (X3,y3) is. The Prince need your help. Can you calculate the C (x3,y3) and tell him? Enter

The ' The ' is ' an integer t (1 <= t <=) which is the number of test cases. T test Cases follow. Each test case contains two coordinates A (x1,y1) and B (X2,y2), described by four, floating-point numbers x1, y1, x2, y2 (| x1|, |y1|, |x2|, |y2| <= 1000.0).
Please notice so A (x1,y1) and B (X2,y2) and C (X3,y3) are in A anticlockwise direction the equilateral. and coordinates A (x1,y1) and B (X2,y2) are given by anticlockwise.     Output For each test case, you should output the coordinate of C (X3,Y3), the result should is rounded to 2 decimal places in a Li NE. sample Input

4
-100.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00 0.00 100.00
100.00
1.00 0.00 1.866 0.50
Sample Output
( -50.00,86.60)
( -86.60,50.00)
( -36.60,136.60)
(1.00,1.00)
Tips Source2013 Shandong Four ACM College students Program Design Competition
The point: In a counter-clockwise order to give two points of coordinates, to find the 3rd coordinate. Make these three points constitute a equilateral.
#include <stdio.h>
#include <math.h>
#define PI acos ( -1.0)
int main ()
{
    int n;
    scanf ("%d", &n);
    while (n--)
    {
        double x1,x2,y1,y2;
        scanf ("%lf%lf%lf%lf", &x1,&y1,&x2,&y2);
        Double t=atan2 (y2-y1,x2-x1) +pi/3.0;
        Double zz=sqrt (POW (x1-x2,2) +pow (y1-y2,2));
        Double X=zz*cos (t) +x1,y=zz*sin (t) +y1;
        printf ("(%.2LF,%.2LF) \ n", x,y);
    }
    return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.