Wireless Network Coverage
Description
Our Lele students have a special liking for the internet. He has a plan to use wireless networks to cover Zhengzhou University.
Now the school gives him a chance, so he wants to buy many wireless routes. Now he is deploying a network on a certain Avenue, and the school only allows his wireless router to be placed in the middle of the road. By default, this avenue is straight and Its width is the same anywhere. All routers have the same coverage area. Now Lele calculates the length and width of this avenue and the coverage radius of the router. Please help him calculate the minimum number of routers he wants to purchase.
Note: To prevent interference, the minimum distance between two wireless routes cannot be less than 1 meter.
The path in Figure 1 is a rectangle, and the dotted line in the middle represents the midline. Figure 2 shows the minimum coverage.
-
Input
-
Input includes multiple groups of test data Part 1: an integer T (1 <= T <= 500) Part 2: A total of T rows, each line includes three integers L, D, R represents the length, width, and coverage radius (meters) of the path ). (1 <= L <= 100000), (1 <= d <= 50), (1 <= r <= 200 ).
-
Output
-
For each group of test data output each occupies one row, there is only one integer, indicating the minimum number of routers. If it cannot be overwritten, output impossible
-
Sample Input
-
240 6 540 10 5
-
Sample output
-
5impossible
#include <iostream>#include <cmath>using namespace std;int main(){ int n; int a,b; cin>>n; while(n--) { int l,d,r;cin>>l>>d>>r;if(4*r*r < 1 + d*d){ cout<<"impossible"<<endl; continue;}double ll = sqrt(4.0*r*r - d*d)/2;double nn = (l/ll) / 2;if((int)(nn*1000000) == (int) nn * 1000000) cout<< (int)nn<<endl;else cout <<(int)nn+1<<endl;}return 0;}
Wireless Network Coverage