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