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

#define ll long long
#define pb push_back
#define x first
#define y second
#define sz(u) (int)(u.size())
#define ld long double
#define all(u) u.begin(),u.end()
# define PI 3.141592653589793238462643383279502884L

using namespace std;



int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	ld n,l,k; cin>>n>>l>>k;
	ld a=0,b=1e9;
	while(abs(b-a)>1e-9){
		ld R = (a+b)/2.L;
		ld h=l/(2.L*tan(PI/n));
		ld ratio=1.L;
		ld r = l/(2.L * sin(PI/n));
		ld alpha=-1;
		if(R<h) ratio=1.L;
		else if(R>=r) ratio=l*l*n/(4.L*tan(180.L/n)*PI*R*R);
		else{
			alpha = acos(l/(2.L * R * tan(PI/n)));
			ratio = 1.L - n*(alpha-l/(2.L * R * tan(PI/n))*sin(alpha))/PI;
		}
		if(ratio>=k/10000.L-1e-9) a=R;
		else b=R;
	}
	cout<<fixed<<setprecision(11)<<(a+b)/2.L;
	return 0;
}
Copy
I Shot the Sheriff medk
GNU G++17
0 ms
512 KB
Wrong Answer