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 ...
随机推荐
- MacDev.GarbageCollectionIsDeprecated-WhenXcodeCompileMacAppProject
Garbage Collection is not supported 当Xcode编译Mac OSX App时报错:"Garbage Collection is not supported ...
- XiaoKL学Python(E)Generator Expressions
在 阅读 https://github.com/vitonzhang/objc_dep 中的 objc_dep.py 时遇到: objc_files = (f for f in files if f. ...
- Startup.国外新锐公司及其技术Blog
国外技术公司Tech/Engineering Blog 1. vimeo https://coderwall.com/team/vimeo http://blog.assembly.com/ 2. l ...
- mysql 多表查询先排序,然后再取分组<mysql 先order by,然后再取group by分组>
select * from ( select cv.lasttime,cm.mailbox,cv.clientip from `co_user_visitlog` as cv INNER JOIN ` ...
- Spring Boot REST(二)源码分析
Spring Boot REST(二)源码分析 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10117436.html) SpringBoot RE ...
- Spring Boot学习笔记:kafka应用
Kafka作为众多Java消息中间件之一,有诸多优点.本文讲解Kafka的应用.学习一个新的知识点,建议先找一个demo,越简单越好的demo,跑通这个demo,了解大致原理,然后在分析细节,详细了解 ...
- iOS中堆和栈的区别
管理方式: 对于栈来讲,是由编译器自动管理,无需我们手工控制:对于堆来讲,释放工作有程序员控制,容易产生memory Leak. 申请大小: 栈:在Windows下,栈是向低地址扩展的数据结构,是一块 ...
- SpringMVC 学习 九 SSM环境搭建 (二) Spring配置文件的编写
spring配置文件中需要干的事情 (一)开启 Service与pojo包的注解扫描 注意:spring 扫描与表对应的实体类,以及service层的类,不能用来扫描Controller层的类,因为 ...
- mysql 5.7 linux环境下解压安装
在CentOS linux环境安装mysql 一般rpm(或者yum),预编译和源码安装. 如果采用rpm或者yum安装,mysql的数据文件一般存放在/var/lib/mysql目录下,也就是会把d ...
- 企业IT资产管理功能大全