Water spraying device (i.)

Source: Internet
Author: User

time limit: theMS | Memory Limit:65535KBDifficulty: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
 
 
 
 
#include <stdio.h> #include <algorithm> #include <math.h>using namespace Std;int main () {int i,j,k,a,b ; scanf ("%d", &a), while (a--) {double x[1000];scanf ("%d", &b), for (i=0;i<b;i++) scanf ("%lf", &x[i]); sort (x,x+b); k=0;double c=20.0;for (i=b-1;i>=0;i--) {c-=sqrt (x[i]*x[i]-1) *2;k++;if (c<=0) break;} printf ("%d\n", k);} return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Water spraying device (i.)

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.