Wannafly Challenge Race B area and math

Source: Internet
Author: User
Tags acos cos

Surface

Test instructions: There is a positive n-side shape, and its center of circumscribed circle is at the origin, and the radius is L. At the center of the origin, r is the radius of a circle, and the area of the positive n-side shape is calculated. 3<=n<=1e8 1<=l<=1e6 0<=r<=1e6

The r>=l is clearly a large circle area

R<=h h is a positive n-side shape, each small isosceles triangle high, H=l*cos (pi/n), (combined with the N-side Bingchang sine formula is pushed down), the answer is obviously positive n-side (S=l*sin (pi/n) *h *n, that is, each small isosceles triangle area *n)

Otherwise, the graph is just n-shaped each paragraph out of a small circular arc around the area, the area is a fan area-the area of the triangle can be

Also note that n is 1e8 l,r is 1e6 n*l*r can have 1e20 plus decimal place, double is not enough

Remember to use long double and %lf output instead of%LF

1#include <bits/stdc++.h>2 #defineLD long Double3 using namespacestd;4 Long DoubleS,al,s,h,n,l,r,pi=acos (-1);5 intMain ()6 {7Cin>>n>>l>>R;8     if(r>=l)9     {Tenprintf"%.2LF", pi*r*R);  One         return 0; A     } -H=l*cos (pi/n); -S=l*sin (pi/n) *h; the     if(r<=h) printf ("%.2LF", s*n); -     Else -     {  -Al=acos (h/R);  +s=al*r*r-r*h*sin (al); -printf"%.2LF", (s+s) *n); +     } A}

Wannafly Challenge Race B area and math

Related Article

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.