I need A offer!

Source: Internet
Author: User

I need A offer! Time limit:2000/1000ms (java/other) Memory limit:65536/32768k (Java/other) total submission (s): 4 Accepted Submiss Ion (s): 2Problem descriptionspeakless wanted to go abroad very early, now he has finished all the required examinations, prepared all the materials to be prepared, so, they need to apply for school. To apply for any university abroad, you have to pay a certain amount of application fees, which is very alarming. Speakless didn't have much money, only a total of n million dollars. He will choose a number of M schools (certainly within his financial range). Each school has a different application fee of a (million dollars), and speakless estimates the likelihood of his getting a offer from this school B. Whether or not there is an offer between different schools will not affect each other. "I need a offer," he shouted. Help the poor man, help him calculate the maximum probability that he can receive at least one offer. (if Speakless chooses more than one school, get an offer from any school).

Input inputs have several sets of data, the first row of each group of data has two positive integers n,m (0<=n<=10000,0<=m<=10000) followed by m rows, each row has two data ai (integer), bi (real type) The application fees and the probability of the possibility of getting an offer are indicated for the first school respectively. The last entry has two 0.

Output each set of data corresponds to an export, indicating the maximum probability that speakless may get at least one offer. Expressed as a percentage, accurate to one decimal place.

Sample Input10 34 0.14 0.25 0.30 0

Sample output44.0%[hint]you should use printf ("percent") to print a '% '. [/hint]: 01 backpack; Code:
#include <stdio.h>#include<string.h>#defineMAX (x, y) (x>y?x:y)Const intmaxn=10010;DoubleBAG[MAXN];intW[MAXN];DoubleV[MAXN];DoubleFvDoubleADoubleb) {//if (a==0) return B;    DoubleC=1-a,d=1-b; return 1-c*D;}intMain () {intn,m;  while(~SCANF ("%d%d", &n,&m), n| |m) {memset (bag,0,sizeof(bag));  for(intI=0; i<m;i++) scanf ("%D%LF",&w[i],&V[i]);  for(intI=0; i<m;i++)             for(intj=n;j>=w[i];j--) Bag[j]=max (BAG[J],FV (bag[j-w[i]],v[i));//less-W "i"bag[n]*= -; printf ("%.1lf%%\n", Bag[n]); }    return 0;}

I need A offer!

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.