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的更多相关文章

  1. HDU 4968 Improving the GPA(dp)

    HDU 4968 Improving the GPA 题目链接 dp.最大最小分别dp一次,dp[i][j]表示第i个人,还有j分的情况,分数能够减掉60最为状态 代码: #include <c ...

  2. HDU 4968 Improving the GPA

    Improving the GPA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  3. hdu 4968 Improving the GPA (水 暴力枚举)

    题目链接 题意:给平均成绩和科目数,求可能的最大学分和最小学分. 分析: 枚举一下,可以达到复杂度可以达到10^4,我下面的代码是10^5,可以把最后一个循环撤掉. 刚开始以为枚举档次的话是5^10, ...

  4. HDU 4968(杭电多校#9 1009题)Improving the GPA (瞎搞)

    题目地址:HDU 4968 这题的做法是全部学科的学分情况枚举,然后推断在这样的情况下是否会符合平均分. 直接暴力枚举就可以. 代码例如以下: #include <cstring> #in ...

  5. hdu String Problem(最小表示法入门题)

    hdu 3374 String Problem 最小表示法 view code#include <iostream> #include <cstdio> #include &l ...

  6. HDU(2485),最小割最大流

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2485 Destroying the bus stations Time Limit: 40 ...

  7. HDU(1853),最小权匹配,KM

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1853 Cyclic Tour Time Limit: 1000/1000 MS (Java/Other ...

  8. HDU 4971 (最小割)

    Problem A simple brute force problem (HDU 4971) 题目大意 有n个项目和m个问题,完成每个项目有对应收入,解决每个问题需要对应花费,给出每个项目需解决的问 ...

  9. hdu 2686 Matrix 最小费用最大流

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2686 Yifenfei very like play a number game in the n*n ...

随机推荐

  1. android 线性布局

    activity_main.xml线性布局 <?xml version="1.0" encoding="utf-8"?> <LinearLay ...

  2. Codeforces 791B. Bear and Friendship Condition 联通快 完全图

    B. Bear and Friendship Condition time limit per test:1 second memory limit per test:256 megabytes in ...

  3. Exception 异常 输出的各个方法的区别

    try{ System.out.println(1/0); }catch(Exception e){ //System.out.println(e+""); //对象+字符串 = ...

  4. Chrome firefox ie等浏览器空格(&nbsp;)兼容问题

    使用(&nbsp:)空格浏览器之间,显示的不一样,对不起等现象. 解决方案: 用半角空格&ensp:或者全角空格&emsp:就可以了,&ensp:相当于半格中文字符的宽 ...

  5. 弹出DIV锁定代码

    <html>  <head>  <meta http-equiv="Content-Type" content="text/html; ch ...

  6. Windows-universal-samples学习笔记系列五:Custom user interactions

    Custom user interactions Basic input Complex inking Inking Low latency input Simple inking Touch key ...

  7. Java学习总结1

    1. 断点调试 a:定位(设置断点)  b:启动调试  c:单步执行  观察变量(F5单步执行   F6单步跳过)d:修改2 static  静态  静态成员,为类的所有对象共享  在静态方法中,只能 ...

  8. 20175316盛茂淞-Java第1周学习总结

    20175316盛茂淞 2018-2019-2 <Java程序设计>第1周学习总结 教材学习内容总结 Java入门 1.Java简介(地位,特点) 2.安装JDK,设置系统环境 3.编译J ...

  9. kbmmw 5.06.00 beta 发布

    原生.高效.可扩展.跨平台通信库来了. we are happy to announce v5.06.00 BETA of our popular middleware for Delphi and  ...

  10. 高效能程序员的七个习惯【csdn】

    从网上看到的,感觉挺不错的! Beautiful is better than ugly. Explicit is better than implicit. Simple is better tha ...