Untitled
unknown
plain_text
9 months ago
3.3 kB
15
Indexable
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int c;
cin >> c;
cout.setf(ios::fixed);
cout << setprecision(15);
const ld PI = acosl(-1.0L);
while (c--) {
ld m, t;
cin >> m >> t;
if (t < 3 * m) {
cout << 0.0 << "\n";
continue;
}
ld best = 0.0;
ld limit = min((ld)1e6L, floor(t / m)); // reasonable bound
for (ld n = 3; n <= limit; ++n) {
ld walk = t - n * m;
if (walk <= 0) break;
ld area = (walk * walk) / (4.0L * n * tanl(PI / n));
if (area > best) best = area;
}
// for huge n, approximate by circle
if (t > 1e6 * m) {
ld walk = t - m * floor(t / m);
ld circ = (walk * walk) / (4.0L * PI);
best = max(best, circ);
}
cout << best << "\n";
}
return 0;
}
}
}
}
}
}Editor is loading...
Leave a Comment