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
-
first row m for 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 numbers Ri,ri indicates that the water spray device can cover The radius of the covered circle.
-
Output
-
number of devices used for output
-
sample input
-
252 3.2 4 4.5 6 101 2 3 1 2 1.2 3 1.1 1 2
-
sample output
-
#include <stdio.h>
#include <math.h>
int Main ()
{
int n;
scanf ("%d", &n),
while (n--)
{
int x,i,j;
double s=0,t;
scanf ("%d", &X);
Double a[x]; defines how many the array is defined in the////loop,
for (i=0;i<x;i++)
scanf ("%lf", &a[i]),//Input water spray device radius
for (i=0 ; i<x-1;i++)
for (j=i;j<x;j++)
{
if (A[i]<a[j])////order from large to small
{
T=a[i];
A[i]=a[j];
A[j] =t;
}
}
i=0;
Double k=0;
while (s<20) ///s is length
{
k=s;
s=s+ (sqrt (a[i]*a[i]-1) *2;////to completely cover the box circle at least over the end of the box
i=i+1;
}
printf ("%d\n", I);
}
}
Water Spray Device Solution