Topic 1435: Fan miasma

Source: Internet
Author: User

Topic 1435: Fan miasma

time limit:1 seconds

Memory limit:128 MB

Special question: No

submitted:5089

Resolution:1314

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
#include <iostream>#include<stdio.h>#include<math.h>#include<algorithm>using namespacestd;intMain () {intC; intn,v,w; intpi[102];  while(SCANF ("%d", &c)! =EOF) {         while(c--) {scanf ("%d%d%d",&n,&v,&v);  for(intI=0; i<n; i++) {scanf ("%d",&Pi[i]); } sort (Pi,pi+N); intans_v=0;//Final Volume            Doubleans_p=0.00;//Final Density            DoubleDl=0.00;//Current substance Content            intTmpvol=0;//Current Volume            DoubleTmpdegree=0.00;//Current Concentration            DoubleTmp= (Double) w/ -;//Maximum concentration             for(intI=0; i<n; i++) {Tmpvol+=v;//each cycle is added volume V;dl+= (Double) pi[i]/ -*v;//the quality of the substances currently addedTmpdegree= (Double) Dl/tmpvol;//the concentration of the current solution                if(tmpdegree<tmp| | Fabs (tmpdegree-tmp) <1e-8) {Ans_v=Tmpvol; Ans_p=Tmpdegree; }                Else                     Break; } printf ("%d%.2lf\n", Ans_v, ans_p); }     }    return 0;} /************************************************************** problem:1435 User:zhuoyuezai language:c++ result:accepted time:10 Ms memory:1520 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.