Uvslive 6324 to seek the expectation of archery coverage

Source: Internet
Author: User

DES: Gives an n line segment. Ask for the desired number of line segments per shot.

Very simple. is the angle between the ends of each segment and the lines connected to the origin. If the angle is greater than pi. is 2pi minus this angle. The final divided by the total value of 2PI is the desired expectation.

Atan2 (y, x). Represents the angle (y, x) of the Ray and the x-axis forward composition.

I don't know if I can think of the game.

#include <stdio.h>#include<string.h>#include<math.h>#include<iostream>#include<iomanip>using namespacestd;intMain () {intT; DoublePI =3.1415926; scanf ("%d", &t);  while(t--)    {        intN; scanf ("%d", &N); intx1, y1, x2, y2; DoubleAns =0.0; Doubletemp;  while(n--) {scanf ("%d%d%d%d", &x1, &y1, &AMP;X2, &y2); Temp= Fabs (atan2 (y1, x1)-atan2 (y2, x2)); if(Temp > Pi) temp =2*PI-temp; Ans+=temp; } ans/=2*Pi; printf ("%.5lf\n", ans); }}
Look

Uvslive 6324 to seek the expectation of archery coverage

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.