hdu 4968 最大最小gpa
http://acm.hdu.edu.cn/showproblem.php?pid=4968
给定平均分和科目数量,要求保证及格的前提下,求平均绩点的最大值和最小值。
dp[i][j]表示i个科目,总分j的情况,离线预处理以后直接输出即可
dp[i + 1][j + k] = max/min(dp[i][j] + gpa[k]);
//去掉60分以下的无用段可以提速.
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include<map>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define clr0(x) memset(x,0,sizeof(x))
double f[12][1200];
double g[12][1200];
double gpa[120]; int main() {
for (int i = 60; i <= 69; i++)
gpa[i] = 2.0;
for (int i = 70; i <= 74; i++)
gpa[i] = 2.5;
for (int i = 75; i <= 79; i++)
gpa[i] = 3;
for (int i = 80; i <= 84; i++)
gpa[i] = 3.5;
for (int i = 85; i <= 100; i++)
gpa[i] = 4.0; for (int i = 0; i <= 10; i++)
for (int j = 0; j <= 1000; j++) {
f[i][j] = -1e9;
g[i][j] = 1e9;
}
f[0][0] = g[0][0] = 0;
for (int i = 0; i < 10; i++) {
for (int j = 0; j <= 1000; j++) {
for (int k = 60; k <= 100; k++) {
f[i + 1][j + k] = max(f[i + 1][j + k], f[i][j] + gpa[k]);
g[i + 1][j + k] = min(g[i + 1][j + k], g[i][j] + gpa[k]);
}
}
} int _;RD(_);
while (_--) {
int k, n;
scanf("%d%d",&k,&n);
printf("%.4lf %.4lf\n",g[n][n * k]/(double)n ,f[n][n * k ]/(double)n);
}
return 0;
}
hdu 4968 最大最小gpa的更多相关文章
- HDU 4968 Improving the GPA(dp)
HDU 4968 Improving the GPA 题目链接 dp.最大最小分别dp一次,dp[i][j]表示第i个人,还有j分的情况,分数能够减掉60最为状态 代码: #include <c ...
- HDU 4968 Improving the GPA
Improving the GPA Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...
- hdu 4968 Improving the GPA (水 暴力枚举)
题目链接 题意:给平均成绩和科目数,求可能的最大学分和最小学分. 分析: 枚举一下,可以达到复杂度可以达到10^4,我下面的代码是10^5,可以把最后一个循环撤掉. 刚开始以为枚举档次的话是5^10, ...
- HDU 4968(杭电多校#9 1009题)Improving the GPA (瞎搞)
题目地址:HDU 4968 这题的做法是全部学科的学分情况枚举,然后推断在这样的情况下是否会符合平均分. 直接暴力枚举就可以. 代码例如以下: #include <cstring> #in ...
- hdu String Problem(最小表示法入门题)
hdu 3374 String Problem 最小表示法 view code#include <iostream> #include <cstdio> #include &l ...
- HDU(2485),最小割最大流
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2485 Destroying the bus stations Time Limit: 40 ...
- HDU(1853),最小权匹配,KM
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1853 Cyclic Tour Time Limit: 1000/1000 MS (Java/Other ...
- HDU 4971 (最小割)
Problem A simple brute force problem (HDU 4971) 题目大意 有n个项目和m个问题,完成每个项目有对应收入,解决每个问题需要对应花费,给出每个项目需解决的问 ...
- hdu 2686 Matrix 最小费用最大流
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 Yifenfei very like play a number game in the n*n ...
随机推荐
- Liunx history
Linux中history历史命令使用方法详解 (转) 作者:青藤园来源:|2012-05-10 10: http://os.51cto.com/art/201205/335040.htm ...
- css font-size=0的妙用
转自:css font-size=0有什么妙用? 回答一: 问题的根源是 inline(a标签默认是display:inline) 和 inline-block (.list-info 设置的是 di ...
- PHP 语句和时间函数
语句 1.分支语句 (1)if例子:$a=9;$b=5;if($a>$b){echo $a."比".$b."大";}else{echo $a." ...
- poj_1979(dfs)
Red and Black There is a rectangular room, covered with square tiles. Each tile is colored either re ...
- (O)js核心:this
什么是this this是js中的一个关键词,它总是指向一个对象,而具体指向哪个对象是在运行时基于函数的执行环境动态绑定的,而非函数被声明时的环境. 当函数被调用时,this被添加到作用域中,例如: ...
- How to program BMW KOMBI and NBTwith ENET E sys cable ICOM A2
This is how to set up Router or DHCP server for BMW KOMBI and NBT programming with Enet e sys cable ...
- CH#17C 舞动的夜晚
原题链接 即求二分图的不可行边数量,因为不保证是完备匹配,所以需要通过网络流求出任意一组最大匹配,并建立新图判断. 建新图:对于跑完网络流的图上已经匹配的边,建立反边:对于没有匹配的边,建立正边(图只 ...
- Python-多线程之消费者模式和GIL全局锁
一.生产者和消费者模式 什么是生产者消费者模式 生产者消费者模式是通过一个容器来解决生产者和消费者的强耦合问题.生产者和消费者彼此之间不直接通讯,而通过阻塞队列来进行通讯, 所以生产者生产完数据之后不 ...
- DP:0
小故事: A * "1+1+1+1+1+1+1+1 =?" * A : "上面等式的值是多少" B : *计算* "8!" A *在上面等式 ...
- mysql mariadb的VC客户端遇到的问题
在使用VS2017编写数据库客户端 具体设置可参见以下内容 https://dev.mysql.com/doc/connector-cpp/en/connector-cpp-apps-windows- ...