Source Code
#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define LL long long
#define LD long double
#define pb push_back
#define F first
#define S second


const double PI=3.1415926535897932384626433;
const int KL=1e6;
const LL MOD=1e9+7;


using namespace std;

LL n;
LD l,k,p,a,b;


bool ok(LD r){
    if(r>=b){
        LD AP=p*a/2;
        LD AC=r*r*PI;
        if(AP/AC>=k)return 1;
        else return 0;
    }
    else {
        LD rl=sqrt(r*r-a*a)*2.0;
        LD AP=(LD)n*rl*a/2.0;
        LD theta=2*PI/n-acos(a/r)*2;
        AP+= n*r*r*theta/2.0;
        LD AC=r*r*PI;
        if(AP/AC>=k)return 1;
        else return false;
    }
}

int main()
{
    cin>>n>>l>>k;
    k/=10000.0;
    p=(LD)n*l,a=l/tan(PI/(LD)n);
    a/=2.0;
    b=sqrt(a*a+l*l/4.0);

    LD lo=a,hi=1e16;
    for(int i=0;i<100;i++){
        LD mid=(lo+hi)/2;
        if(ok(mid))lo=mid;
        else hi=mid;
    }
    cout<<fixed<<setprecision(10)<<lo<<endl;


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