Water spraying device (a) time limit: theMs | Memory Limit:65535KB Difficulty:3
-
-
Describe
-
Existing a lawn, a length of 20 meters, a width of 2 meters, to place a radius of Ri on the Central line of the water spray device, each sprinkler effect will let its center radius for the real Ri (0<ri<15) of the circle is moist, there is sufficient water spray device I (1<i<600) , and must be able to wet all the lawn, what you have to do is: choose as little as possible water spray device, the whole lawn moist.
-
-
Input
-
The
-
first line m indicates that there is a m group of test data
The first line of each set of test data has an integer number N,n represents a total of n water jets, followed by a row of n real Ri,ri that indicate the radius of the circle that the water spray device can cover.
-
-
Output
-
-
number of devices used in the output
-
-
Sample input
-
-
252 3.2 4 4.5 6 101 2 3 1 2 1.2 3 1.1 1 2
-
-
Sample output
-
-
25
Because the size of the matrix is 2, it simplifies a lot of operations ...
As long as the length of the hypotenuse of the lawn is calculated, then as long as the radius of the whole circle is greater than or equal to half the length of the hypotenuse (but a device with a radius of less than or equal to 1 must be discarded, it cannot cover the grass completely, regardless of how it is placed on the horizontal midline).
x = sqrt (r*r-(H/2) * (H/2)), so that a circle with a radius of R can cover a length of 2x, leaving the w-2x, and then traversing down, when w<=0, it is satisfied.
R=SQRT (X*X+H*H)/2 Total R = sqrt (w*w+h*h)/2
To simplify, the radius of all circles (less than or equal to 1) is equal to half the length of the hypotenuse.
#include <iostream>02. #include <algorithm>03. #include <cmath>04. #include <cstdio>05.using namespace Std;06.const Double PI = ACOs ( -1.0); 07.int Main () 08. {09.int N,m;10.cin>>n;11.while (n--) 12. {13.double a[610];14.int m;15.cin>>m;16.for (int i = 0; i < m; i++) Cin>>a[i];17.sort (a,a+m); 18.double sum = 0;19.double len = sqrt (20*20 + 2*2)/2;20.int count = 0;21.for (int i = m-1; I >=0; i--) 22. {23.sum + = A[i];24.count++;25.if (Sum > Len) break;26.} 27.cout<<count<<endl;28.} 29.return 0;30.}
Water spraying device (i.)