Water Spray Device Solution

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.