Source Code
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<int, int> pi;
const ll Mod = 998244353;
const ll INF = (ll)(1e18) + 5;
const ll N = 1e6 + 5, M = 18;

int main() {
	GO;
	ll n, len, k;
	cin >> n >> len >> k;
	double pi = acos(-1);
	double pr = double(len) / 2 / sin(pi / n);
	double pl = pr * cos(pi / n);
	double res = -1;
	double l = 0, r = 1000 * pr;
	for (int i = 0; i < 200; i++) {
		double mid = (l + r) / 2;
		double s;
		double c = pi * mid * mid;
		if (mid <= pl)
			s = c;
		else if (mid >= pr)
			s = pl * len / 2 * n;
		else {
			double angle = acos(pl / mid) * 2;
			double base = mid * sin(angle / 2) * 2;
			s = angle / 2 * mid * mid - base * pl / 2;
			s = n * s;
			s = c - s;
		}
		if (s / c >= double(k) / 10000)
			res = l = mid;
		else r = mid;
	}
	cout << fixed << setprecision(9) << res << '\n';
	return 0;
}
Copy
I Shot the Sheriff Oxygen
GNU G++17
0 ms
860 KB
Accepted