Test instructions: Given an R and H,r is the radius of the upper hemisphere, h is the height of the column below, and then there are some balloons with a radius of R/2, asking you to put up a few.
Analysis: According to test instructions, it is easy to know, first from below to put up, two two of the put, put to not put the time, and then calculate in the above is not can put another. This is the most important, the key is to calculate the above can be put on, using the geometry of the two-circle position relationship,
It can be seen from the bottom of the balloon, the ball can be up to the dome and the cylindrical intersection, so we can easily calculate two two of the put, up to a few groups, that is, H + R whole divided by R, to Integer, and then calculate the next round,
The highest circle is exactly the hemisphere tangent, we can use the hemisphere heart as the origin, the establishment of a coordinate system, then the circle is (0, R/2), and then calculate the top of the circle is not and it is absent or tangent, if it is can be put on, if not, will not put on.
The code is as follows:
#include <bits/stdc++.h>using namespace Std;const int maxn = 33333 + 5;typedef long long ll;const double EPS = 1e-9; int A[10];int Main () { LL R, H; while (CIN >> R >> h) { Double rr = R * 1.0/2.0; Double x = RR + (double) h; ll ans = (ll) (X/R); Double y = sqrt (3)/2.0 * r + H-ans * r; Double yy = sqrt (3)/2.0 * R-Y; YY-= RR; Double d = RR * RR + (YY-RR) * (YY-RR); if (D-4*rr*rr > EPs) cout << ans * 2 + 1 << endl; else cout << ans * 2 << Endl; } return 0;}
Codeforces 342C Cupboard and balloons (geometry problem)