Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535
#define fast ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef pair<ll,ll> pli;
typedef pair<int,int> pii;
typedef pair<ld,ld> pld;
ll MOD=1000000007 ;
ll MX=1000000000000000;

ld n,l,k;
double x;
double ans;
ld res;
ld f(ld r)
{
    ld d=l/2.0/tan(PI/n);
    ld p=l/2.0/sin(PI/n);
    if(r<=d)
        return 1;
    if(r>=p)
        return (2.0*n*l/2.0*d/2.0)/(PI*r*r);
    ld y=d;
    ld x=sqrt(r*r-d*d);
    ld theta=asin(x/r);
    ld area=(theta*r*r-x*d)*n;
    return (1.0-area/(PI*r*r));

}
int main()
{
    fast;
    //freopen("input.txt","r",stdin);
    scanf("%lf",&x);
    n=x;
    scanf("%lf",&x);
    l=x;
    scanf("%lf",&x);
    k=x;
    ld lo=l/2.0/tan(PI/n);
    ld hi=1e8;
    ld eps=0.0000000001;
    while(hi-lo>=eps)
    {
        ld mid=(lo+hi)/2;
        //cout<<lo<<" "<<hi<<" "<<mid<<" "<<f(mid)<<endl;
        if(f(mid)>=k/10000.0)
        {
            lo=mid;
        }
        else
        {
            hi=mid;
        }
    }
    ans=lo;
    printf("%.9lf\n",ans);



    return 0;
}
Copy
I Shot the Sheriff Mr_Programmer_98
GNU G++17
0 ms
856 KB
Accepted