Topic 1435: Fan miasma

Source: Internet
Author: User

Title Description:

Through the cliffs of the Yifenfei, but also facing the test of the Glen-
The miasma around the glen, the eerie stillness, loomed over the floor with skeletons. Because of the long darkness here, the air is covered with toxins, once inhaled in the body, it will fester and die.
Fortunately Yifenfei early preparedness, ready to understand the pharmaceutical materials (various concentrations of universal potions). Now just follow the configuration into different proportions of the concentration.
Yifenfei is now known to carry a universal potion of N Concentration, Volume V is the same, the concentration is pi% respectively. And know, for the miasma of the valley at that time, just select some or all of the universal potion, and then configure the concentration of less than w% potions can be detoxification.
Now the question is: How can you configure this medicine to get the maximum volume of the currently available antidote?
Special note: Due to the limitations of the equipment in the Glen, only one of the existing medicines is allowed to be mixed into another (i.e., no action can be taken on a drug that only takes part of it).

Input:

The first line of input data is an integer c, representing the number of groups of test data;
Each set of test data contains 2 rows, the first line gives three positive integers n,v,w (1<=n,v,w<=100);
The next line is n integers representing the concentration pi% (1<=pi<=100) of the N potion.

Output:

For each set of test data, output an integer and a floating-point number;
where integers represent the maximum size of the antidote, floating-point numbers indicate the concentration of the antidote (rounded to retain 2 decimal places);
If it is not possible to match the required antidote, please output 0 0.00.

Sample input:
31 100 101002 100 2420 303 100 2420 20 30
Sample output:
0 0.00100 0.20300 0.23

Determine if floating-point numbers are equal:

The input integer is 15, is actually saved to 14.999999999999999 by the double type, and then another computed 15 is saved to 15.0000000000001 by a double variable, so while the direct comparison will result in a condition less than the latter, But in fact this inequality is caused by the loss of precision of double.
So when judging if two floating-point numbers are "equal", use a

    1. if (Fabs (A-B) < EPS)

。 Among them, Fabs is the absolute value function, A, B is two double type number, EPS is a very small floating point, usually take 1e-8.

Greedy algorithm:

1 Importjava.util.Arrays;2 ImportJava.util.Scanner;3  4  Public classmain{5      Public Static voidMain (string[] args) {6Scanner in=NewScanner (system.in);7         intnum=in.nextint ();8          for(inti=0;i<num;i++){9             intn=in.nextint ();Ten             intv=in.nextint (); One             intw=in.nextint (); A             int[]p=New int[n]; -              for(intj=0;j<n;j++){ -p[j]=in.nextint (); the             } - Arrays.sort (P); -             intCout=0; -             DoubleSum=0; +              for(intj=0;j<n;j++){ -                 if((Sum+p[j])/(cout+1) <=4) { +sum+=P[j]; Acout++; at                 } -             } -               -             if(cout==0) -System.out.printf ("%d%.2f\n", cout*v,0.0); -             Else inSystem.out.printf ("%d%.2f\n", Cout*v, (sum*v)/(cout*100*V)); -         } to     } + } - /************************************************************** the problem:1435 * user:0000h $ Language:javaPanax Notoginseng result:accepted - time:180 Ms the memory:20204 KB + ****************************************************************/

Topic 1435: Fan miasma

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.