题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=1203

思路

求最少能收到一份offer的最大概率,可以先求对立面:一份offer也收不到的最小概率,然后使用1减去最小概率即可。由于一份offer也收不到的最小概率需要用乘法来解决,所以该题的状态转移方程为: dp[j] = min(dp[j], dp[j - v[i]] * w[i]) ,其中v[i]为第i个申请的申请费,w[i]为第i个申请收不到offer的概率,dp[j]为在j万美元的情况下,所有的申请全部都没有获得offer的最小概率。注意数组dp[]要初始化为1。

代码

 #include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std; const int N = + ;
int v[N];
double w[N];
double dp[N]; int main()
{
//freopen("hdoj1203.txt", "r", stdin);
int n, m;
while (cin >> n >> m && (n + m))
{
for (int i = ; i < m; i++)
{
cin >> v[i] >> w[i];
w[i] = - w[i];
} for (int i = ; i <= n;i++)
dp[i] = ;
for (int i = ; i < m; i++)
{
for (int j = n; j >= v[i]; j--)
dp[j] = min(dp[j], dp[j - v[i]] * w[i]);
}
printf("%.1lf%%\n", ( - dp[n]) * );
}
return ;
}

最新文章

  1. (C# &amp; Unity) 脚本语言 ES
  2. Android的RecyclerView
  3. mysql5.6-5.7性能调优
  4. 史上最全最强SpringMVC详细示例实战教程
  5. 智能车学习(十一)&mdash;&mdash;陀螺仪学习
  6. 0518Scrum项目5.0
  7. javascript学习随笔(二)原型prototype
  8. Dijkstra + 优先队列优化 模板
  9. Android OpenGL ES(一)----必备知识
  10. Python对象初探
  11. 食物卡喉别拍背部!救了100多万人性命的“海姆立克急救法&quot;
  12. C# 操作 Word 修改word的高级属性中的自定义属性
  13. Google的Java经常使用类库 Guava
  14. 批处理+组策略 实现规定时间段无法开机and定时关机
  15. Android Stdio 中的Rendering Problems Android N requires the IDE to be running with Java 1.8 or later Install a supported JDK解决办法
  16. Spark 1.0 开发环境构建:maven/sbt/idea
  17. UIViewController/ApplicationSequ…
  18. vue中使用vue-quill-editor及上传图片到自己服务器
  19. TensorFlow——循环神经网络基本结构
  20. 斯坦福大学公开课机器学习:advice for applying machine learning | diagnosing bias vs. variance(机器学习:诊断偏差和方差问题)

热门文章

  1. PHP里echo print print_r的区别
  2. CF&amp;&amp;CC百套计划1 Codeforces Round #449 C. Willem, Chtholly and Seniorious (Old Driver Tree)
  3. poj 1284 Primitive Roots (原根)
  4. 你知道吗?undefined 与 null 的区别
  5. don&#39;t run elasticsearch as root.
  6. 【leetcode 简单】 第七十六题 移动零
  7. Spring4笔记10--SSH整合1--Spring与Hibernate整合
  8. 爬虫基础---HTTP协议理解、网页的基础知识、爬虫的基本原理
  9. URIEncoding与useBodyEncodingForURI 在tomcat中文乱码处理上的区别
  10. vue总结 04过渡--进入/离开 列表过渡