POJ 2976
来源:互联网 发布:debian和centos哪个好 编辑:程序博客网 时间:2024/05/21 07:04
又发现新东西了哇咔咔
话说每天都能学到新的是不是因为我太弱了(什么都没见过%>_<%)
传说中的01分数规划问题的裸题。
从n组数中干掉k组数使最后的比例最大,于是二分答案排序一下再判定就好了。
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;double a[1005],b[1005],d[1005];int n,k;bool check(double l){for(int i=1;i<=n;i++)d[i]=a[i]-b[i]*l;sort(d+1,d+1+n);double x=0;for(int i=k+1;i<=n;i++)x+=d[i];return x>0;}int main(){while(scanf("%d%d",&n,&k)&&n){for(int i=1;i<=n;i++)scanf("%lf",&a[i]);for(int i=1;i<=n;i++)scanf("%lf",&b[i]);double l=0.0,r=1.0,mid;while(r-l>(1e-7)){mid=(l+r)*1.0/2;if(check(mid))l=mid;else r=mid;}printf("%.0f\n",mid*100);}return 0;}
0 0
- POJ-2976
- POJ 2976
- POj 2976
- 【POJ】2976
- POJ 3104&&POJ 2976 继续二分搜索。。。
- POJ 2976 参数搜索
- poj 2976 Dropping tests
- POJ 2976 Dropping tests
- poj 2976 分数规划
- POJ 2976 Dropping tests
- poj 2976-Dropping tests
- POJ 2976 Dropping tests
- POJ 2976 Dropping tests
- POJ-2976-Dropping tests
- poj 2976 Dropping tests
- POJ 2976 Dropping tests
- Poj 2976 Dropping tests
- poj 2976(二分)
- iOS中ARC与MRC混编
- 通过苹果官网下载最新稳定的xcode方法
- 优先队列一点小用法
- android中启动第三方apk
- activeMq消息队列查询统计
- POJ 2976
- cocos2dx中IOS/Android跨平台微信登录和分享
- 我的unity生涯开始了
- K-means算法浅析
- 加载模式
- LeetCode Permutation Sequence
- K-means算法的介绍
- hihocoder #1184 : 连通性二·边的双连通分量
- 纪录激活方式