I NEED A OFFER!

Problem Description
Speakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然要在他的经济承受范围内)。每个学校都有不同的申请费用a(万美元),并且Speakless估计了他得到这个学校offer的可能性b。不同学校之间是否得到offer不会互相影响。“I NEED A OFFER”,他大叫一声。帮帮这个可怜的人吧,帮助他计算一下,他可以收到至少一份offer的最大概率。(如果Speakless选择了多个学校,得到任意一个学校的offer都可以)。
 

Input
输入有若干组数据,每组数据的第一行有两个正整数n,m(0<=n<=10000,0<=m<=10000) 
后面的m行,每行都有两个数据ai(整型),bi(实型)分别表示第i个学校的申请费用和可能拿到offer的概率。 
输入的最后有两个0。
 

Output
每组数据都对应一个输出,表示Speakless可能得到至少一份offer的最大概率。用百分数表示,精确到小数点后一位。
 

Sample Input
10 3 4 0.1 4 0.2 5 0.3 0 0
 

Sample Output
44.0%
题解:使用01背包+概率或者排序+贪心。。。。。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int x[11111];
double y[11111],p[11111];
double max(double a,double b){
	return a>b?a:b;
}
int main(){
	int n,m;
	while(cin >> n >> m){
		if(n==0 && m==0) break;
		memset(p,0,sizeof(p));
		for(int i=0;i<m;i++){
			cin >> x[i] >> y[i];
		}
		for(int i=0;i<m;i++){
			for(int j=n;j>=x[i];j--){
				p[j]=max(p[j],1-(1-p[j-x[i]])*(1-y[i]));
			}
		}
		printf("%.1lf%%\n",p[n]*100);
	}
	return 0;
}
 

Dear Friend ; Especially for you - this amazing announcement . This is a one time mailing there is no need to request removal if you won't want any more ! This mail is being sent in compliance with Senate bill 2316 , Title 1 ; Section 303 ! This is not a get rich scheme . Why work for somebody else when you can become rich in 77 months . Have you ever noticed society seems to be moving faster and faster and more people than ever are surfing the web ! Well, now is your chance to capitalize on this ! We will help you turn your business into an E-BUSINESS and sell more . You can begin at absolutely no cost to you . But don't believe us . Ms Ames who resides in Indiana tried us and says "Now I'm rich, Rich, RICH" . We are licensed to operate in all states . If not for you then for your LOVED ONES - act now ! Sign up a friend and you'll get a discount of 30% ! Thank-you for your serious consideration of our offer . Dear Colleague ; Your email address has been submitted to us indicating your interest in our letter ! This is a one time mailing there is no need to request removal if you won't want any more ! This mail is being sent in compliance with Senate bill 2516 ; Title 1 , Section 304 . This is not a get rich scheme ! Why work for somebody else when you can become rich inside 34 months ! Have you ever noticed how long the line-ups are at bank machines plus people will do almost anything to avoid mailing their bills ! Well, now is your chance to capitalize on this ! We will help you process your orders within seconds and deliver goods right to the customer's doorstep ! You are guaranteed to succeed because we take all the risk ! But don't believe us . Mr Simpson of Oregon tried us and says "I've been poor and I've been rich - rich is better" . We are licensed to operate in all states . We urge you to contact us today for your own future financial well-being . Sign up a friend and you get half off . Thank-you for your serious consideration of our offer . Dear Salaryman ; Your email address has been submitted to us indicating your interest in our briefing . This is a one time mailing there is no need to request removal if you won't want any more ! This mail is being sent in compliance with Senate bill 1625 , Title 8 , Section 301 ! This is different than anything else you've seen ! Why work for somebody else when you can become rich in 38 weeks . Have you ever noticed how many people you know are on the Internet and nearly every commercial on television has a .com on in it ! Well, now is your chance to capitalize on this ! WE will help YOU deliver goods right to the customer's doorstep plus increase customer response by 160% ! You can begin at absolutely no cost to you . But don't believe us ! Prof Simpson who resides in Idaho tried us and says "I was skeptical but it worked for me" ! We are licensed to operate in all states ! We IMPLORE you - act now . Sign up a friend and you'll get a discount of 30% . Thanks . 找出flag
最新发布
05-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值