POJ 2976 Dropping tests(分数规划)】的更多相关文章

POJ - 2976 Dropping tests 你有 \(n\) 次考试成绩, 定义考试平均成绩为 \[\frac{\sum_{i = 1}^{n} a_{i}}{\sum_{i = 1}^{n} b_{i}}\] 你可以考虑放弃 \(K\) 次成绩, 求最大平均成绩 * 100 小插曲: 被精度卡成喜羊羊 0/1分数规划\(from\)人生导师 Solution 01分数规划(不是很)裸题, 在每次 \(check\) 时, 选取较大的 \(num - K + 1\) 次即可 Code #…
最大化平均值 有n个物品的重量和价值分别wi 和 vi.从中选出 k 个物品使得 单位重量 的价值最大. 限制条件: <= k <= n <= ^ <= w_i <= v_i <= ^6 输入:n = 3k = 2{W, V} = {(2,2), (5,3), (2,1)} 输出:0.75 (如果选0号和2号,平均价格是 (2 + 1) / (2 + 2) = 0.75) 题解: 一般先想到的肯定是:把物品按照  单位价值  进行排序,然后从大到小贪心地进行选取.但是这…
题目链接:http://poj.org/problem?id=2976 Dropping tests Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17838   Accepted: 6186 Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumula…
Dropping tests Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11367   Accepted: 3962 Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be . Give…
Dropping tests   Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6373   Accepted: 2198 [Description] In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be . G…
Dropping tests Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:17069   Accepted: 5925 Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be . Given…
http://poj.org/problem?id=2976 题意: 给出ai和bi,ai和bi是一一配对的,现在可以删除k对,使得的值最大. 思路: 分数规划题,可以参考<挑战程序竞赛>第144页. 枚举答案x,然后去判断是否存在$\frac{\sum a[i]}{\sum b[i]}>=x$,现在把这个式子转换一下,变成$\sum a[i]-x*\sum b[i]>=0$,这样每次贪心选择前面最大的n-k个即可,判断和x的大小关系. #include<iostream&g…
Dropping tests Time Limit: 1000MS Memory Limit: 65536K Description In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be Given your test scores and a positive integer k, d…
传送门:http://poj.org/problem?id=2976 题意:给出组和,去掉对数据,使得的总和除以的总和最大. 思路:0/1分数规划 设,则(其中等于0或1) 开始假设使得上式成立,将从大到小排序,只取前个(这样一定是最优的),若所得和大于0,则表示偏小,反之偏大. 代码: #include<iostream> #include<algorithm> #include<cstdio> using namespace std; const double ep…
0/1分数规划问题,用二分解决!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #define pi acos(-1.0) using namespace std; ],b[],an[]; int main() { int i,j,k,n; doubl…