HDU 4968 Improving the GPA——暴力

网友投稿 575 2022-11-29

HDU 4968 Improving the GPA——暴力

HDU 4968 Improving the GPA——暴力

五层循环,暴力求解

#include #include using namespace std;const int INF = 0x3f3f3f3f;int main(){ int T; scanf("%d", &T); while (T--) { double average, n; scanf("%lf %lf", &average, &n); double total = average * n, maxans = 0, minans = INF; for (int a = 0; a <= n; a++) { for (int b = 0; b <= n - a; b++) { for (int c = 0; c <= n - a - b; c++) { for (int d = 0; d <= n - a - b - c; d++) { for (int e = 0; e <= n - a - b - c - d; e++) { double down = a * 85 + b * 80 + c * 75 + d * 70 + e * 60; double up = a * 100 + b * 84 + c * 79 + d * 74 + e * 69; if (a + b + c + d + e == n && down <= total && total <= up) { double ans = a * 4 + b * 3.5 + c * 3 + d * 2.5 + e * 2; maxans = max(maxans, ans); minans = min(minans, ans); } } } } } } printf("%.4lf %.4lf\n", minans / n, maxans / n); } return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:UVa 1600 Patrol Robot——bfs
下一篇:HDU 1754 I Hate It——单点更新的线段树
相关文章

 发表评论

暂时没有评论,来抢沙发吧~