Zoj 3806 incircle and circumcircle [] [Special Judge]

Source: Internet
Author: User

Question link: http://acm.zju.edu.cn/onlinejudge/showProblem.do? Problemcode = 3806.

Calculate the outer circle radius and incircle radius of a triangle and the three sides of the triangle that meet the given conditions.

The example given by the question is a bit difficult... it is easy to mislead people.

Sample Input
 
1 22 59 9
Sample ouput
 
3.464101615137754587 3.464101615137754587 3.4641016151377545876 8 10no solution!

The answer to the two and five examples is three integers. So it may be misleading.

When I first saw the question, I was misled by the example. I had no idea, but I found a special case after drawing it on paper for a long time.

The center of the incircle and the incircle given by YY is above a straight line, and then the relationship between length x and angle α can be obtained based on the sine theorem and a series of deformation.




Then the mathematical formula shows that the formula of angle α and X is

X = (1 + 1/sin (α)/(2-2 * sin (α ))

According to the formula binary sin (α)

The value range of sin (α) is 0 ~ 1. Compare the size of input x and re-determine the upper and lower bounds. (This function is incremental)

After sin (α) is obtained, three sides of the triangle can be obtained based on the x size and α angle.

Note that the radius of the incircle is 1 by default after the transformation. Therefore, the three sides of the triangle must be multiplied by R/R.

# Include <iostream> # include <math. h> # include <cstring> # include <stdio. h >#include <algorithm> using namespace STD; # define EPS 1e-11double Er (Double X) {double L = 0, r = 1, mid; while (L <R) {mid = (L + r)/2; // printf ("%. 9lf %. 9lf \ n ", l, R); double temp = (1.0 + 1.0/Mid)/(2.0-2.0 * (mid * mid )); if (temp-x> EPS) L = mid; else if (temp + EPS <X) r = mid; else break;} // printf ("%. 13lf \ n ", mid); return mid;} int main () {doubl E n, m; while (~ Scanf ("% lf", & N, & M) {double Bi = M/N; If (Bi-2) <-EPS) {printf ("no solution! \ N "); continue;} double SiNx = ER (BI); double cosx = SQRT (1-sinx * SiNx); Double Y = (1.0 + 1.0/SiNx)/cosx; double T = (1.0 + SiNx)/cosx; printf ("%. 18lf %. 18lf %. 18lf \ n ", y * n, y * n, 2 * T * n );}}
Ignore the definition of my function name and the appearance of an ER (BI )........

zoj 3806 incircle and circumcircle [ry] [Special Judge]

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.