HDU 1700 math problems

Source: Internet
Author: User


First, we can find the circle radius, and then use two formulas to solve the equations.

A * B = | a | * | B | * cos (120 );

X * x + y * y = r * r;

There are exactly two solutions for solving the equation, and they are for the sake.

 


The Code is as follows:

Here is a circle with a radius of r. The circle center is located at the origin, let you find that the two points on the circle are the maximum distance between the two points and the given point. Obviously, they are the maximum distance between each other at 120 degrees. # Include <iostream> # include <cstdio> # include <cstdlib> # include <cmath> # include <cstring> # include <string> # include <vector> # include <list> # include <deque> # include <queue> # include <iterator> # include <stack> # include <map> # include <set> # include <algorithm> # include <cctype> using namespace std; typedef long LL; const int N = 21; const ll ii = 1000000007; double x, y, r, r2; double xx0, yy0, xx1, yy1; int main () {int T; cin> T; while (T --) {scanf ("% lf", & x, & y ); r2 = (x * x + y * y); double a, B, c; a = r2; B = r2 * y; c = r2 * r2/4-x * x * r2; yy0 = (-B-sqrt (B * B-4 * a * c)/2/; yy1 = (-B + sqrt (B * B-4 * a * c)/2/; /*/This place to solve x can not use x * x + y * y = r2 to calculate, should not know the positive and negative number xx0 = sqrt (r2-yy0 * yy0 ); xx1 = sqrt (r2-yy1 * yy1); */if (fabs (x-0) <1e-7) {xx0 =-sqrt (r2-yy0 * yy0 ); xx1 = sqrt (r2-yy1 * yy1);} else {xx0 = (-r2/2-yy0 * y)/x; xx1 = (-r2/2-yy1 * y)/x ;} printf ("%. 3lf %. 3lf %. 3lf %. 3lf \ n ", xx0, yy0, xx1, yy1);} 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.