Source Code
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy

ll n, k, l;
ld a, tmp_, r;
const ld pi = 3.14159265359;
bool check(ld x){
	ld tmp = sqrt(x*x-a*a);
	ld a1 = a*tmp;
	ld ang = 2.0*atan2(tmp,a);
	ld a2 = x*x*pi*ang/(2*pi);
	ld a3 = x*x*pi-(a2-a1)*n;
	ld c = x*x*pi;
	// cout<<x<<" "<<a3/c<<endl;
	return c*k<=a3*10000;
}

int main(){
// int t;cin>>t;while(t--){
	scanf("%lld%lld%lld",&n,&l,&k);
	a = l/(2*tan(pi/n));
	r = hypot(a, l/2.0);
	// cout<<r<<endl;
	// n * a² * cot(π/n) / 4
	tmp_ = l*n*a/2.0;
	ld c = pi*r*r;
	if(c*k<=tmp_*10000){
		ld st = r, nd = 10000*k/c+10000, md, t = 500;
		while(t--){
			// cout<<md<<endl;
			md = (st+nd)/2.0;
			c = pi*md*md;
			if(c*k<=tmp_*10000){
				st = md;
			}
			else{
				nd = md;
			}
		}
		cout<<fixed<<setprecision(12)<<st<<endl;
	}
	else{
		ld st = a, nd = r, md, t = 500;
		while(t--){
			md = (st+nd)/2.0;
			c = pi*md*md;
			if(check(md)){
				st = md;
			}
			else{
				nd = md;
			}
		}
		cout<<fixed<<setprecision(12)<<st<<endl;
	}

// }
return 0;
}
Copy
I Shot the Sheriff Zain
GNU G++17
0 ms
744 KB
Wrong Answer