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)alpha = PI/(2*n);
			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) 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
360 KB
Wrong Answer