Hdu1203 -- d-I need a offer! (Convert 01 backpack)

Source: Internet
Author: User

D-  I need a offer! Time limit:1000MS  Memory limit:32768KB  64bit Io format:% I64d & % i64u Submit   Status

 

Description

Speakless wanted to go abroad very early. Now he has completed all the required tests and prepared all the materials to be prepared, so he needs to apply for a school. To apply for a foreign university, you have to pay a certain amount of application fee, which is amazing. Speakless does not cost much, and only saves tens of thousands of dollars in total. He will select several of M schools (of course, within his economic limits ). Each school has a different application fee (USD), and speakless estimates that he is more likely to receive an offer from the school. Whether an offer is obtained from different schools does not affect each other. "I need a offer", he shouted. Help this poor person. Help him calculate the maximum probability that he can receive at least one letter of offer. (If you select multiple schools for speakless, you can get an offer from any school ).

Input

The input has several groups of data. The first row of each group of data has two positive integers, N, and M (0 <= n <= random, 0 <= m <= 10000) 
In the next m row, each row has two data types: AI (integer type) and Bi (real type), which respectively indicate the application fee of the I-th School and the probability of obtaining an offer.  
The last two zeros are entered.

Output

Each group of data corresponds to an output, indicating that speakless may obtain the maximum probability of at least one offer. Expressed as a percentage, accurate to the last decimal point.

Sample Input

 
10 34 0.14 0.25 0.30 0

Sample output

44.0%

Hint

 
You shoshould use printf ("%") to print a '% '. 

 

Given the probability of obtaining an offer, it is difficult to calculate the probability of obtaining an offer after several schools, but it is not easy to calculate, we only need to multiply all the impossible probabilities, so the question is converted to the lowest possible probability, and it becomes a simple 01 backpack.

# Include <cstdio> # include <cstring> # include <algorithm> using namespace STD; double DP [20000]; int main () {int n, m, W, I, j; Double K; while (scanf ("% d", & N, & M )! = EOF) {If (n = 0 & M = 0) break; for (I = 0; I <= N; I ++) DP [I] = 1.0; for (I = 0; I <m; I ++) {scanf ("% d % lf", & W, & K ); k = 1.0-K; For (j = N; j> = W; j --) DP [J] = min (DP [J], DP [J-W] * k);} printf ("%. 1lf % \ n ", (1.0-dp [N]) * 100);} return 0 ;}


 

Hdu1203 -- d-I need a offer! (Convert 01 backpack)

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.