Source Code
/// Fuck Them, Fuck Me, and Fuck You
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ii = pair<int, int>;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

const int N = 1e6 + 5, LG = 19, MOD = 1e9 + 7;
#define int ll
ll prCosts[N], k;
int n;
int sieve[N];
ll ans[N];
const long double PI = acos(-1.0);
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE

    int n, l, k;
    cin >> n >> l >> k;


    long double r = 1.0L * l / (2.0L * sin(PI / n));
    long double polygonArea = (1.0L * l * n) * (1.0L * l / (2.0L * tan(PI / n))) / 2.0L;
    ///pi*r^2
    if(polygonArea / (PI * r * r) >= k / 10000.0L) {    ///circumcircle

        long double lo = r, hi = 1e9;
        for(int j = 0; j < 200; j++) {
            long double md = (lo+hi)/2.0;
            if(polygonArea / (PI * md * md) >= k / 10000.0L) {
                lo = md;
            }   else hi = md;
        }
        cout << lo << '\n';
        return 0;
    }

    ///at least innercircle
    long double r2 = 1.0L * l / (2.0L * tan(PI / n));
    long double lo = r2, hi = r;

    for(int j = 0; j < 200; j++) {
        long double md = (lo + hi) / 2.0;
        long double lft = md - r2;
        long double h = (md - r2);
        long double toSubtract = md * md * acos((md - h) / md) - (md - h) * sqrtl(2.0L * md * h - h * h);
        toSubtract *= n;
        long double circleArea = PI * md * md;
        long double polygonArea = PI * md * md - toSubtract;
//        cout << md << ' ' << polygonArea / circleArea << ' ' << k / 10000.0L << endl;
        if(polygonArea / circleArea >= k / 10000.0L)
            lo = md;
        else
            hi = md;
    }

    cout << lo << '\n';



    return 0;
}
Copy
I Shot the Sheriff DeadlyPillow
GNU G++17
0 ms
360 KB
Wrong Answer