Problem W
NEED A
OFFER”,他大叫一声。帮帮这个可怜的人吧,帮助他计算一下,他可以收到至少一份offer的最大概率。(如果Speakless选择了多个学校,得到任意一个学校的offer都可以)。
后面的m行,每行都有两个数据ai(整型),bi(实型)分别表示第i个学校的申请费用和可能拿到offer的概率。
输入的最后有两个0。
#include
#include
#include
#define maxn 10010
using namespace std;
int main()
{
//freopen("in.txt", "r", stdin);
int
n,m,money[maxn];
double
offer[maxn],dp[maxn];
while(scanf("%d%d",&n,&m)!=EOF&&(n+m))
{
memset(dp,0,sizeof dp);
for(int i=0;i
{
scanf("%d%lf",&money[i],&offer[i]);
//cout<<money[i]<<"
"<<offer[i]<<endl;
}
for(int i=0;i
{
for(int j=n;j>=money[i];j--)
{
dp[j]=max(dp[j],1-(1-dp[j-money[i]])*(1-offer[i]));
//1-找不到学校的概率
//printf("%.5lf\n",dp[j]);
}
//printf("%.5lf\n",dp[i]);
}
printf("%.1f%%\n",dp[n]*100);
}
return
0;
}
Problem W的更多相关文章
- Problem W UVA 662 二十三 Fast Food
Fast Food Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status P ...
- Problem W: 零起点学算法21——求平均值
#include<stdio.h> int main() { int a,b,c; scanf("%d %d %d",&a,&b,&c); pr ...
- 菜鸟带你飞______DP基础26道水题
DP 158:11:22 1205:00:00 Overview Problem Status Rank (56) Discuss Current Time: 2015-11-26 19:11:2 ...
- [kuangbin带你飞]专题十四 数论基础
ID Origin Title 111 / 423 Problem A LightOJ 1370 Bi-shoe and Phi-shoe 21 / 74 Problem B ...
- (https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014550004)Topic: Caught java.io.CharConversionException. ERRORCODE=-4220, SQLSTATE=null
270002WDPN 3 Posts 0 people l ...
- 近年Recsys论文
2015年~2017年SIGIR,SIGKDD,ICML三大会议的Recsys论文: [转载请注明出处:https://www.cnblogs.com/shenxiaolin/p/8321722.ht ...
- Policy Gradient Algorithms
Policy Gradient Algorithms 2019-10-02 17:37:47 This blog is from: https://lilianweng.github.io/lil-l ...
- lucene入门创建索引——(二)
1.程序宏观结构图
- Ubuntu 16.04出现:Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh > /dev/null; fi'
错误: Reading package lists... Done E: Problem executing scripts APT::Update::Post-Invoke-Success 'if ...
随机推荐
- vue.js项目构建
这里构建的vue.js项目依赖node服务器运行. 项目搭建完整步骤: 安装node.js ,转至nodeJs网站http://nodejs.cn/ 下载nodeJs进行安装. 安装完毕检查nodeJ ...
- Spring 3.x 读书笔记
第一:如果使用BeanFactory作为Spring Bean的工厂类,则所有的bean都是在第一次使用该Bean的时候实例化 第二:如果使用ApplicationContext作为Spring Be ...
- 用sqlserver的自定义函数直接获取多级部门全名
好久没写存储过程了,今日正好同事的开发需要,实现显示多级部门的部门全名称. 如 财务部/会计部/会计一部 部门表 人员表 函数 getOrgAllName --OrgID 72 当前的部门ID A ...
- MySQL数据库设计基础
为什么需要规范的数据库设计? 什么是数据库设计? 数据库设计就是将数据库中的数据实体及这些数据实体之间的关系,进行规划和结构化的过程. 数据库设计非常重要! 数据库中创建的数据结构的种类,以及在数据实 ...
- C++格式化输出的好东西
s = FormatFloat("0.######", d); 最多保留6位s = FormatFloat("0.000000", d); 始终保留6位s = ...
- Ubuntu16.04 install android-studio-ide-162.4069837-linux
本文讲解如何在Ununtu 16.04上安装jdk.Android Sdk.Anroid Studio.Genymotion.AndroidStudio与Genymotion绑定. 由于第一次装了双系 ...
- web前端面试官挖的那些坑(js)
题目1: function Foo() { getName = function () { alert (1); }; return this; } Foo.getName = function () ...
- C# Async/await 异步多线程编程
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...
- 关于KVO导读
入门篇 KVO是什么? Key-value observing is a mechanism that allows objects to be notified of changes to spec ...
- Android的快速开发框架 afinal
afinal 框架学习: http://www.oschina.net/p/afinal