BNUOJ34977 the brightest star in the night sky (mathematical and vector applications) and bnuoj34977 the night sky

Source: Internet
Author: User

BNUOJ34977 the brightest star in the night sky (mathematical and vector applications) and bnuoj34977 the night sky
Brightest star in the night skyTime Limit:2000 msMemory Limit:65536KB64-bit integer IO format: % lld Java class name: MainPrev Submit Status Statistics Discuss NextFont Size:+ -

If you don't get lost in a strange place, it is very important to clearly identify the direction. watching the stars is a good helper method. In a period of time, the arrangement of stars in the sky remains almost unchanged at the same time every night. The brightness and darkness of each star have an identifier, called a star, which is expressed by a real number. The smaller the value of this real number, the more bright the stars are. The stars that can be seen in bright cities are in the range -~ About 3.5.

Map students are afraid to lose the title of Map. Every night, they work hard to write down the layout of the Emperor's stars. Standing in the north direction, he maps the sky he sees to a huge Cartesian coordinate system, so each star has a coordinate.

On this day, Map came to the beautiful Harbin and looked up to see the brightest stars, Jupiter and the second brightest North River. He stood in the north as he thought, and computed their coordinates as in the imperial capital. But in fact, he doesn't always find the north by intuition. In addition, there is no way to grasp the scale Size of the used coordinate system.

Now he wants to know the minimum number of angles that need to be converted before he can face the north.

Input

The number of first behavior data groups t (t <= 1000 ).

Next, for each group of data:

The first action n (2 <= n <= 1000) indicates the number of stars seen in the imperial capital the day before.

The following are n rows and each row has three real numbers, including the coordinates and stars of n stars.

The last row contains four real numbers, which are the coordinates of Jupiter and the North River.

The absolute value of the preceding real number cannot exceed 1000. Take 3.14159265358 for π.

Output

Output a row, which is the minimum angle to be converted and retains three decimal places.

Sample Input
120 0 -21 0 00 0 0 1.2
Sample Output
90.000
Source 12th Beijing Normal University Program Design Competition finals Prev Submit Status Statistics Discuss Next
#include<stdio.h>#include<math.h>#define PI 3.14159265358typedef struct nnn{    double x,y,d;}node;int main(){    int t,n;    double s,jd,x,y,dis[2];    node star[2],st[2],xl[2];    scanf("%d",&t);    while(t--)    {        scanf("%d",&n);        jd=10000;        star[0].d=star[1].d=10000;        for(int i=0;i<n;i++)        {            scanf("%lf%lf%lf",&x,&y,&s);            if(s<star[0].d)            {                star[1].x=star[0].x;                star[1].y=star[0].y;                star[1].d=star[0].d;                star[0].x=x; star[0].y=y; star[0].d=s;            }            else if(s<star[1].d)            {                star[1].x=x; star[1].y=y; star[1].d=s;            }        }        for(int i=0;i<2;i++)        scanf("%lf%lf",&st[i].x,&st[i].y);        xl[0].x=star[0].x-star[1].x;        xl[0].y=star[0].y-star[1].y;        dis[0]=sqrt(xl[0].x*xl[0].x+xl[0].y*xl[0].y);        xl[1].x=st[0].x-st[1].x;        xl[1].y=st[0].y-st[1].y;        dis[1]=sqrt(xl[1].x*xl[1].x+xl[1].y*xl[1].y);        jd=180.0/PI*acos((xl[0].x*xl[1].x+xl[0].y*xl[1].y)/(dis[0]*dis[1]));        if(jd>180)jd=360-jd;        printf("%.3lf\n",jd);    }}





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.