1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 #include <vector>
 5 #include <map>
 6 using namespace std;
 7 const int inf = 0x3f3f3f3f;
 8 const int MAX = +;
 9 double GPA[],dp1[][],dp2[][];
 map<int,int> hash;
 void init() {
     memset(GPA,,sizeof(GPA));
     for(int i=;i<=;i++) hash[i]=;
     for(int i=;i<=;i++) hash[i]=;
     for(int i=;i<=;i++) hash[i]=;
     for(int i=;i<=;i++) hash[i]=;
     for(int i=;i<=;i++) hash[i]=;
     GPA[]=2.0; GPA[]=2.5; GPA[]=3.0;
     GPA[]=3.5; GPA[]=4.0;
     memset(dp2,,sizeof(dp2));
     for(int i=;i<=;i++) {
         for(int j=;j<=;j++) dp1[i][j]=inf;
     }
     for(int i=;i<=;i++) {
         dp1[][i]=GPA[hash[i]];
         dp2[][i]=GPA[hash[i]];
     }
     for(int i=;i<=;i++) {
         for(int v=;v<=;v++) {
             for(int j=;j<=;j++) {
                 if(v>=j) {
                     if(i==) {
                         dp1[i][v]=min(dp1[i][v],dp1[i-][v-j]+GPA[hash[j]]);
                         dp2[i][v]=max(dp2[i][v],dp2[i-][v-j]+GPA[hash[j]]);
                     }
                     else if(((double)(v-j)/(double)(i-))>=) {
                         dp1[i][v]=min(dp1[i][v],dp1[i-][v-j]+GPA[hash[j]]);
                         dp2[i][v]=max(dp2[i][v],dp2[i-][v-j]+GPA[hash[j]]);
                     }
                 }
             }
         }
     }
 
 
 }
 int main() {
     int n,cnt,ave; init();
     scanf("%d",&n);
     while(n--) {
         scanf("%d %d",&ave,&cnt);
         int tot=ave*cnt;
         printf("%.4lf %.4lf\n",dp1[cnt][tot]/(double)cnt,dp2[cnt][tot]/(double)cnt);
     }
     return ;
 }

Improving the GPA

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 181    Accepted Submission(s): 148

Problem Description
Xueba: Using the 4-Point Scale, my GPA is 4.0.

In fact, the AVERAGE SCORE of Xueba is calculated by the following formula:
AVERAGE SCORE = ∑(Wi * SCOREi) / ∑(Wi) 1<=i<=N
where SCOREi represents the scores of the ith course and Wi represents the credit of the corresponding course.

To simplify the problem, we assume that the credit of each course is 1. In this way, the AVERAGE SCORE is ∑(SCOREi) / N. In addition, SCOREi are all integers between 60 and 100, and we guarantee that ∑(SCOREi) can be divided by N.

In SYSU, the university usually uses the AVERAGE SCORE as the standard to represent the students’ level. However, when the students want to study further in foreign countries, other universities will use the 4-Point Scale to represent the students’ level. There are 2 ways of transforming each score to 4-Point Scale. Here is one of them. 

The student’s average GPA in the 4-Point Scale is calculated as follows:GPA = ∑(GPAi) / N
So given one student’s AVERAGE SCORE and the number of the courses, there are many different possible values in the 4-Point Scale. Please calculate the minimum and maximum value of the GPA in the 4-Point Scale. 

 

Input
The input begins with a line containing an integer T (1 < T < 500), which denotes the number of test cases. The next T lines each contain two integers AVGSCORE, N (60 <= AVGSCORE <= 100, 1 <= N <= 10).
 

Output
For each test case, you should display the minimum and maximum value of the GPA in the 4-Point Scale in one line, accurate up to 4 decimal places. There is a space between two values.
 

Sample Input
4 75 1 75 2 75 3 75 10
 

Sample Output
3.0000 3.0000 2.7500 3.0000 2.6667 3.1667 2.4000 3.2000

有是一道傻比dp,没判不合法情况逗比3小时才过。

HDU 4968 (水dp 其他?)的更多相关文章

  1. Tickets HDU - 1260 水DP

    HDU - 1260 现在有n个人要买电影票,如果知道每个人单独买票花费的时间, 还有和前一个人一起买花费的时间,问最少花多长时间可以全部买完票. 直接dp就行,注意下输出和初始化 每次从dp[i-1 ...

  2. HDU 4968 Improving the GPA(dp)

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

  3. HDU 2084 数塔 (水DP)

    题意:.... 析:从下往上算即可,水DP. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #incl ...

  4. hdu 2571 命运(水DP)

    题意: M*N的grid,每个格上有一个整数. 小明从左上角(1,1)打算走到右下角(M,N). 每次可以向下走一格,或向右走一格,或向右走到当前所在列的倍数的列的位置上.即:若当前位置是(i,j), ...

  5. CodeForces 706C Hard problem (水DP)

    题意:对于给定的n个字符串,可以花费a[i]  将其倒序,问是否可以将其排成从大到小的字典序,且花费最小是多少. 析:很明显的水DP,如果不是水DP,我也不会做.... 这个就要二维,d[2][max ...

  6. hdu 4123 树形DP+RMQ

    http://acm.hdu.edu.cn/showproblem.php? pid=4123 Problem Description Bob wants to hold a race to enco ...

  7. hdu 4507 数位dp(求和,求平方和)

    http://acm.hdu.edu.cn/showproblem.php?pid=4507 Problem Description 单身! 依旧单身! 吉哥依旧单身! DS级码农吉哥依旧单身! 所以 ...

  8. hdu 3709 数字dp(小思)

    http://acm.hdu.edu.cn/showproblem.php?pid=3709 Problem Description A balanced number is a non-negati ...

  9. 水dp第二天(背包有关)

    水dp第二天(背包有关) 标签: dp poj_3624 题意:裸的01背包 注意:这种题要注意两个问题,一个是要看清楚数组要开的范围大小,然后考虑需要空间优化吗,还有事用int还是long long ...

随机推荐

  1. JSON(2)JSONObject解析Josn和创建Jsonf示例

    1.解析Json /* * test.josn内容如下: { "languages":[ {"id":"1","name" ...

  2. AJPFX:学习JAVA程序员两个必会的冒泡和选择排序

    * 数组排序(冒泡排序)* * 冒泡排序: 相邻元素两两比较,大的往后放,第一次完毕,最大值出现在了最大索引处* * 选择排序 : 从0索引开始,依次和后面元素比较,小的往前放,第一次完毕,最小值出现 ...

  3. flex弹性布局操练2

    上一个是练习的1个内元素的,这次练习两个元素的. ul.box1 { list-style:none; background-color:black; display:flex; justify-co ...

  4. JavaScript - try catch finally throw

    语法: try { tryCode - 尝试执行代码块 } catch(err) { catchCode - 捕获错误的代码块 } finally { finallyCode - 无论 try / c ...

  5. Ajax请求WebService跨域问题

    1.背景 用Jquery中Ajax方式在asp.net开发环境中WebService接口的调用 2.出现的问题 原因分析:浏览器同源策略的影响(即JavaScript或Cookie只能访问同域下的内容 ...

  6. jQuery 点击查看 收起

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. asp 读取 另外一个带参数的asp文件(服务器不支持!放弃吧!骚年!)

    (服务器不支持!放弃吧!骚年!) 主要作用是为了分离数据库,灵感是这样的:收到json影响,把asp里的数据,用一个页面输出,然后用另外一个页面读取,这样就不用有数据库位置的烦恼了 代码 网上有很多, ...

  8. CAD参数绘制多段线(com接口)

    多段线又被称为多义线,表示一起画的都是连在一起的一个复合对象,可以是直线也可以是圆弧并且它们还可以加不同的宽度. 主要用到函数说明: _DMxDrawX::PathLineTo 把路径下一个点移到指定 ...

  9. python 删除/查找重复项

    l = [1,2,3,2,1] # l = ['你','我','他','她','你'] for i in l: print("the %s has found %s" % (i, ...

  10. vue+VeeValidate 校验范围(部分校验,全部校验)

    搜索很久,没有发现有关于vue+VeeValidate部分校验的.自己写一个. 主要是两个场景: 1. 校验范围内,所有的字段. 2. 校验全局所有字段.主要方法: 1.validate(fields ...