HDU 4968 (水dp 其他?)

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
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.
4 75 1 75 2 75 3 75 10
3.0000 3.0000 2.7500 3.0000 2.6667 3.1667 2.4000 3.2000
有是一道傻比dp,没判不合法情况逗比3小时才过。
HDU 4968 (水dp 其他?)的更多相关文章
- Tickets HDU - 1260 水DP
HDU - 1260 现在有n个人要买电影票,如果知道每个人单独买票花费的时间, 还有和前一个人一起买花费的时间,问最少花多长时间可以全部买完票. 直接dp就行,注意下输出和初始化 每次从dp[i-1 ...
- HDU 4968 Improving the GPA(dp)
HDU 4968 Improving the GPA 题目链接 dp.最大最小分别dp一次,dp[i][j]表示第i个人,还有j分的情况,分数能够减掉60最为状态 代码: #include <c ...
- HDU 2084 数塔 (水DP)
题意:.... 析:从下往上算即可,水DP. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #incl ...
- hdu 2571 命运(水DP)
题意: M*N的grid,每个格上有一个整数. 小明从左上角(1,1)打算走到右下角(M,N). 每次可以向下走一格,或向右走一格,或向右走到当前所在列的倍数的列的位置上.即:若当前位置是(i,j), ...
- CodeForces 706C Hard problem (水DP)
题意:对于给定的n个字符串,可以花费a[i] 将其倒序,问是否可以将其排成从大到小的字典序,且花费最小是多少. 析:很明显的水DP,如果不是水DP,我也不会做.... 这个就要二维,d[2][max ...
- hdu 4123 树形DP+RMQ
http://acm.hdu.edu.cn/showproblem.php? pid=4123 Problem Description Bob wants to hold a race to enco ...
- hdu 4507 数位dp(求和,求平方和)
http://acm.hdu.edu.cn/showproblem.php?pid=4507 Problem Description 单身! 依旧单身! 吉哥依旧单身! DS级码农吉哥依旧单身! 所以 ...
- hdu 3709 数字dp(小思)
http://acm.hdu.edu.cn/showproblem.php?pid=3709 Problem Description A balanced number is a non-negati ...
- 水dp第二天(背包有关)
水dp第二天(背包有关) 标签: dp poj_3624 题意:裸的01背包 注意:这种题要注意两个问题,一个是要看清楚数组要开的范围大小,然后考虑需要空间优化吗,还有事用int还是long long ...
随机推荐
- 题解报告:poj 2689 Prime Distance(区间素数筛)
Description The branch of mathematics called number theory is about properties of numbers. One of th ...
- DB2:在缓冲池 "1" 中当前没有任何页面可用。. SQLCODE=-1218, SQLSTATE=57011, DRIVER=3.61.75
服务器端DB2数据库最近频繁报错: 在缓冲池 , SQLSTATE=, DRIVER= 试验发现简单的查询SQL执行没有问题,复杂的SQL就会报上述错误. 百度发现是因为数据库bufferpool太小 ...
- OC中protocol、category和继承的关系--转
开放封闭原则(OCP)就是,“对扩展开放,对更改封闭”.是所有面向对象设计的一个核心宗旨.感兴趣的可以看百度百科的一些解释:http://baike.baidu.com/view/2493421.ht ...
- 473 Matchsticks to Square 火柴拼正方形
还记得童话<卖火柴的小女孩>吗?现在,你知道小女孩有多少根火柴,请找出一种能使用所有火柴拼成一个正方形的方法.不能折断火柴,可以把火柴连接起来,并且每根火柴都要用到.输入为小女孩拥有火柴的 ...
- [完美方案+无懈可击]ubuntu 14.04(LTS) + GTX 980Ti显卡配置
安装好系统之后出现的问题: 1 不能上网:后来通过删除链接新建一个以太网链接(自动DHCP)重启莫名其妙就好使了. 2 分辨率只有两个:1024x ? 和 800x600. 分辨率低到让人头痛.通过查 ...
- WebForm 开发方式,简单使用
ASP开发方式 格式 <% %> C#代码可以写在里面 <%= %> 往外输出一个值,可以放一个变量,一个方法(这个方法是有返回值的直接打印到界面上去) <%@ %& ...
- 三种将list转换为map的方法(传统方法、jdk8 Stream流、guava)
三种将list转换为map的方法 - jackyrong - ITeye博客:http://jackyrong.iteye.com/blog/2158009
- css3中content属性的应用
可以使用css3中content功能为html元素增减内容.content需要配合 E:before和E:after使用. 废话少说,看代码和效果说明: 第一种: css代码: #div1:befor ...
- 用css制作圆环图表 (vue,sass)
效果图: 思路 :在一个容器里再放两个矩形,每个矩形都占一半,给这两个矩形都设置溢出隐藏,当去旋转矩形里面的圆形的时候,溢出部分就被隐藏掉了,这样就可以达到想要的效果. 代码-html: <di ...
- 博客之旅 gogogo!
听说写博客的人都很牛~ 上班一年多了,想记录点什么,so,就写博客吧,整理一些技术点与工作生活心得 欢迎各位道友交流学习 :)