题意:p, q,都是整数.

sigma(Ai * ki)>= p,

sigma(B* ki) >= q;

ans = sigma(ki)。输出ans的最小值

约束条件2个,但是变量k有100000个,所以可以利用对偶性转化为求解

ans = p * y1 + q * y2

约束条件为:

Ai * y1 + Bi * y2 <= 1 其中i为0~n-1

也就是n个约束条件。 后面三分搞搞就好了

 #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + ;
double A[maxn], B[maxn], p, q;
int n;
double check(double x){
double y = 1e20;
for (int i = ; i < n; i++){
y = min(y, (-A[i]*x)/B[i]);
}
return p * x + y * q;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
while (~scanf("%d%lf%lf", &n, &p, &q)){
for (int i = ; i < n; i++){
scanf("%lf%lf", A+i, B+i);
}
double l = , r = 1.0/(*max_element(A, A+n));
for (int i = ; i < ; i++){
double ml = (l + l + r) / ;
double mr = (r + r + l) / ;
if (check(ml) > check(mr)){
r = mr;
}else{
l = ml;
}
}
printf("%.20f\n", check((l+l)/));
}
return ;
}

Codeforces Round #335 (Div. 1)--C. Freelancer's Dreams 线性规划对偶问题+三分的更多相关文章

  1. Codeforces Round #335 (Div. 1) C. Freelancer's Dreams 计算几何

    C. Freelancer's Dreams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contes ...

  2. Codeforces Round #335 (Div. 2) B. Testing Robots 水题

    B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...

  3. Codeforces Round #335 (Div. 2) D. Lazy Student 构造

    D. Lazy Student Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/606/probl ...

  4. Codeforces Round #335 (Div. 2) C. Sorting Railway Cars 动态规划

    C. Sorting Railway Cars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/conte ...

  5. Codeforces Round #335 (Div. 2) A. Magic Spheres 水题

    A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...

  6. Codeforces Round #335 (Div. 2) D. Lazy Student 贪心+构造

    题目链接: http://codeforces.com/contest/606/problem/D D. Lazy Student time limit per test2 secondsmemory ...

  7. Codeforces Round #335 (Div. 2)

    水 A - Magic Spheres 这题也卡了很久很久,关键是“至少”,所以只要判断多出来的是否比需要的多就行了. #include <bits/stdc++.h> using nam ...

  8. Codeforces Round #335 (Div. 2) A. Magic Spheres 模拟

    A. Magic Spheres   Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. ...

  9. Codeforces Round #335 (Div. 2) D. Lazy Student 贪心

    D. Lazy Student   Student Vladislav came to his programming exam completely unprepared as usual. He ...

随机推荐

  1. C# Chart圖標綁定

    开发软件为VS2010 免去了安装插件之类的麻烦. 最终效果图: 饼状图: 前台设置:设置参数为: :Titles, 添加一个序列,在Text中设置名字. :Series ,添加一个序列,选择Char ...

  2. ORACLE 中ROWNUM用法总结!(转)

    对于 Oracle 的 rownum 问题,很多资料都说不支持>,>=,=,between...and,只能用以上符号(<.<=.!=),并非说用>,>=,=,be ...

  3. SQL中使用的一些函数问题

    abs()取绝对值ceil()上取整floor()下取整initcap()使串中的所有单词的首字母变为大写substr()取子串 这些函数都是oracle的sql内置函数.

  4. UIView下使用Animation控制动画

    转载自:http://blog.csdn.net/xunyn/article/details/8128031 动画效果是IOS界面重要的特色之一,其中CAAnimation是所有动画对象的抽象父类,作 ...

  5. 十、C# 异常处理

    1.多异常类型 2.捕捉异常 3.常规catch块 4.异常处理的指导原则 5.定义自定义异常   1.多异常类型 代码要引发任何异常,只需为要引发的异常实例实例附加关键字throw作为前缀.具体选择 ...

  6. Composite 模式的实现

    实现要点: 1.组合模式采用树形结构来实现普遍存在的对象容器,从而将“一对多”的关系转化“一对一”的关系,使得客户代码可以一致地处理对象和对象容器,无需关心处理的是单个的对象,还是组合的对象容器. 2 ...

  7. js实现滑动解锁功能(PC+Moblie)

    http://dummyimage.com/600x400/ http://placehold.it/140x70 实现效果: css样式代码略. html代码: 页面上导入了jquery.mobil ...

  8. 自构BeanHandler(用BeansUtils)

    class BeanHandler<T> implements ResultSetHandler<T>{ private Class<T> clazz; publi ...

  9. 汇总前端最最常用的JS代码片段

    html5选择器 //参数均接收一个合法的css选择器 element = document.querySelector('.foo,.bar');//返回带有foo或者bar样式类的首个元素 ele ...

  10. js文字向上滚动代码

    js文字向上滚动代码 <style>.pczt_pingfen_jhxs_news1{ width:397px;  background:#edfafd; padding-top:2px; ...