Improving the GPA

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

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

Hint

In the third case, there are many possible ways to calculate the minimum value of the GPA in the 4-Point Scale.

For example,
Scores 78 74 73 GPA = (3.0 + 2.5 + 2.5) / 3 = 2.6667
Scores 79 78 68 GPA = (3.0 + 3.0 + 2.0) / 3 = 2.6667
Scores 84 74 67 GPA = (3.5 + 2.5 + 2.0) / 3 = 2.6667
Scores 100 64 61 GPA = (4.0 + 2.0 + 2.0) / 3 = 2.6667
 
 
题意:前面的都是废话,重要的是GPA = ∑(GPAi) / N,看懂这个和那张表就可以了,
   说白了,就是让你求平均绩点;
思路:最小的绩点就让成绩尽量往前靠,反之,最大的绩点就是让成绩尽量往后靠,这里指的是区间段;
 
 
ps:http://acm.hdu.edu.cn/showproblem.php?pid=4968
 
#include<stdio.h>
#include<string.h>
int l[]= {,,,,};
int r[]= {,,,,};
double gpa[]= {2.0,2.5,3.0,3.5,4.0}; int avg,N,sum,P,Q;
double maxgpa,mingpa;
bool flag; void dfs1(int t1,int t2,int a,int b,double c)
{
if(flag) return ;
if(t2==&&a<=sum&&b>=sum)
{
mingpa=c;
flag=true;
return ;
}
if(t1>||t2==) return ;
for(int i=t2; i>=; i--)
{
dfs1(t1+,t2-i,a+l[t1]*i,b+r[t1]*i,c+gpa[t1]*i);
}
}
void dfs2(int t1,int t2,int a,int b,double c)
{
if(flag) return ;
if(t2==&&a<=sum&&b>=sum)
{
maxgpa=c;
flag=true;
return ;
}
if(t1<||t2==) return ;
for(int i=t2; i>=; i--)
{
dfs2(t1-,t2-i,a+l[t1]*i,b+r[t1]*i,c+gpa[t1]*i);
}
} int main()
{
int T,i,j,k,l;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&avg,&N);
sum=avg*N;
maxgpa=mingpa=; flag=false;
dfs1(,N,,,);
flag=false;
dfs2(,N,,,);
printf("%.4lf %.4lf\n",mingpa/N,maxgpa/N);
}
return ;
}

dfs自己还用的不是很好,比赛的时候等我写完,我们队的其他人已经过了。。。。。

Improving the GPA(hdu4968)dfs的更多相关文章

  1. HDU 4968 Improving the GPA(dp)

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

  2. HDOJ(1010)DFS+剪枝

    Tempter of the Bone http://acm.hdu.edu.cn/showproblem.php?pid=1010 #include <stdio.h> #include ...

  3. POJ2676 – Sudoku(数独)—DFS

    Sudoku Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 24081   Accepted: 11242   Specia ...

  4. LeetCode 5215. 黄金矿工(Java)DFS

    题目: 5215. 黄金矿工 你要开发一座金矿,地质勘测学家已经探明了这座金矿中的资源分布,并用大小为 m * n 的网格 grid 进行了标注.每个单元格中的整数就表示这一单元格中的黄金数量:如果该 ...

  5. Java实现 蓝桥杯 算法提高 GPA(暴力)

    试题 算法提高 GPA 问题描述 输入A,B两人的学分获取情况,输出两人GPA之差. 输入格式 输入的第一行包含一个整数n表示A的课程数,以下n行每行Si,Ci分别表示第i个课程的学分与A的表现. G ...

  6. BZOJ 1064 假面舞会(NOI2008) DFS判环

    此题,回想Sunshinezff学长给我们出的模拟题,原题啊有木有!!此处吐槽Sunshinezff爷出题不人道!! 不过也感谢Sunshinezff学长的帮助,我才能做出来.. 1064: [Noi ...

  7. How far away ?(LCA)dfs和倍增模版

    How far away ? Tarjan http://www.cnblogs.com/caiyishuai/p/8572859.html Time Limit: 2000/1000 MS (Jav ...

  8. 步步为营(十五)搜索(一)DFS 深度优先搜索

    前方大坑预警! 先讲讲什么是搜索吧. 有一天你去一个果园摘梨子,果农告诉你.有一棵树上有一个金子做的梨子,找到就是你的,你该怎么找? 地图例如以下: S 0 0 0 0 0 0 0 0 0 0 0 0 ...

  9. 深度优先搜索(Depth-First-Search)dfs代码模板

    void dfs()//参数用来表示状态 { if(到达终点状态) { ...//根据需求添加 return; } if(越界或者是不合法状态) return; if(特殊状态)//剪枝,去除一些不需 ...

随机推荐

  1. ASP.NET MVC的切片(Section)脚本(script)

    在ASP.NET MVC使用切片脚本,实在是很溜. 在使用layout之后,只是视图套用_Layout之后,在视图中任一位置任一时候均可以使用切片脚本. 首先在_Layout.cshtml定一些规则: ...

  2. 【转】ABP webapi三种方式

    作者:圣杰 链接:https://www.jianshu.com/p/d14733432dc2 來源:简书 著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 1. 引言 上一节我们 ...

  3. 【转】JS浮点数运算Bug的解决办法

    37.5*5.5=206.08 (JS算出来是这样的一个结果,我四舍五入取两位小数) 我先怀疑是四舍五入的问题,就直接用JS算了一个结果为:206.08499999999998 怎么会这样,两个只有一 ...

  4. #loj3089 [BJOI2019]奥术神杖

    卡精度好题 最关键的一步是几何平均数的\(ln\)等于所有数字取\(ln\)后的算术平均值 那么现在就变成了一个很裸的01分数规划问题,一个通用的思路就是二分答案 现在来考虑二分答案的底层怎么写 把所 ...

  5. pcre库

    pcre : perl compatible  regular expressions , perl 兼容正则表达式 www.pcre.org 按装pcre是为了使Nginx支持具备URI重写功能的 ...

  6. eslint 配置及规则说明

    中文官方网站 安装 可以全局安装,也可以在项目下面安装. 如下是在项目中安装示例,只需要在 package.json 中添加如下配置,并进行安装: “eslint”: “^4.11.0” 配置 配置方 ...

  7. Angular使用总结 --- 搜索场景中使用rxjs的操作符

    在有input输入框的搜索/过滤业务中,总会考虑如何减少发起请求频率,尽量使每次的请求都是有效的.节流和防抖是比较常见的做法,这类函数的实现方式也不难,不过终归还是需要自己封装.rxjs提供了各种操作 ...

  8. js获取n分钟(或n小时或n个月)后(或前)的时间(日期)

    标题有点绕,其实意思就是根据系统当前时间,获取n分钟或n小时或n个月后的时间. 例如:当前时间下,获取10分钟后的时间. var date=new Date(); //1. js获取当前时间 var ...

  9. 开发ASP.NET MVC 在线录音录像(音视频录制并上传)

    最近有个在线招聘录音的开发需求,需要在招聘网站上让招聘者上传录音和视频. 找到两个不错的javascript开源,可以在除了IE以外的浏览器运行. https://github.com/mattdia ...

  10. redis集成相关工具类

    package cn.yiyuan.util; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; i ...