九度OJ 1002:Grading
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:18410
解决:4753
- 题目描述:
-
Grading hundreds of thousands of Graduate Entrance Exams is a hard work. It is even harder to design a process to make the results as fair as possible. One way is to assign each exam problem to 3 independent experts. If they do not agree to each other,
a judge is invited to make the final decision. Now you are asked to write a program to help this process.
For each problem, there is a full-mark P and a tolerance T(<P) given. The grading rules are:
• A problem will first be assigned to 2 experts, to obtain G1 and G2. If the difference is within the tolerance, that is, if |G1 - G2| ≤ T, this problem's grade will be the average of G1 and G2.
• If the difference exceeds T, the 3rd expert will give G3.
• If G3 is within the tolerance with either G1 or G2, but NOT both, then this problem's grade will be the average of G3 and the closest grade.
• If G3 is within the tolerance with both G1 and G2, then this problem's grade will be the maximum of the three grades.
• If G3 is within the tolerance with neither G1 nor G2, a judge will give the final grade GJ.
- 输入:
-
Each input file may contain more than one test case.
Each case occupies a line containing six positive integers: P, T, G1, G2, G3, and GJ, as described in the problem. It is guaranteed that all the grades are valid, that is, in the interval [0, P].
- 输出:
-
For each test case you should output the final grade of the problem in a line. The answer must be accurate to 1 decimal place.
- 样例输入:
-
20 2 15 13 10 18
- 样例输出:
-
14.0
思路:
基本的单个数据处理题,主要考察分支判断代码撰写。
代码:
#include <stdio.h>
#include <stdlib.h> #define N 1000 double t; double aver(double a, double b)
{
return (a+b)/2;
} int tol(double i, double j)
{
return abs(i-j)<=t;
} double max(double a, double b, double c)
{
a = (a>b) ? a : b;
a = (a>c) ? a : c;
return a;
} int main(void)
{
double p, g1, g2, g3, gj;
double score; while (scanf("%lf", &p) != EOF)
{
scanf("%lf%lf%lf%lf%lf", &t, &g1, &g2, &g3, &gj); if (tol(g1, g2))
score = aver(g1, g2);
else if (tol(g1, g3) && tol(g2, g3))
score = max(g1, g2, g3);
else if (tol(g1, g3))
score = aver(g1, g3);
else if (tol(g2, g3))
score = aver(g2, g3);
else
score = gj;
printf("%.1lf\n", score);
} return 0;
}
/**************************************************************
Problem: 1002
User: liangrx06
Language: C
Result: Accepted
Time:0 ms
Memory:912 kb
****************************************************************/
九度OJ 1002:Grading的更多相关文章
- 九度oj 1002 Grading 2011年浙江大学计算机及软件工程研究生机试真题
#include<iostream> #include<queue> #include<cstdio> #include<cstring> #inclu ...
- 九度oj题目1002:Grading
//不是说C语言就是C++的子集么,为毛printf在九度OJ上不能通过编译,abs还不支持参数为整型的abs()重载 //C++比较正确的做法是#include<cmath.h>,cou ...
- hdu 1284 关于钱币兑换的一系列问题 九度oj 题目1408:吃豆机器人
钱币兑换问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- 【九度OJ】题目1176:树查找 解题报告
[九度OJ]题目1176:树查找 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1176 题目描述: 有一棵树,输出某一深度的所有节点 ...
- 【九度OJ】题目1445:How Many Tables 解题报告
[九度OJ]题目1445:How Many Tables 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1445 题目描述: ...
- 【九度OJ】题目1109:连通图 解题报告
[九度OJ]题目1109:连通图 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1109 题目描述: 给定一个无向图和其中的 ...
- 九度oj 题目1087:约数的个数
题目链接:http://ac.jobdu.com/problem.php?pid=1087 题目描述: 输入n个整数,依次输出每个数的约数的个数 输入: 输入的第一行为N,即数组的个数(N<=1 ...
- 九度OJ 1502 最大值最小化(JAVA)
题目1502:最大值最小化(二分答案) 九度OJ Java import java.util.Scanner; public class Main { public static int max(in ...
- 九度OJ,题目1089:数字反转
题目描述: 12翻一下是21,34翻一下是43,12+34是46,46翻一下是64,现在又任意两个正整数,问他们两个数反转的和是否等于两个数的和的反转. 输入: 第一行一个正整数表示测试数据的个数n. ...
随机推荐
- 全栈技术经理——团队管理:每周问问你的团队这这些问题 V1.0
全栈技术经理--团队管理:每周问问你的团队这这些问题 V1.0 1.本周取得了哪些进展? 通过回答这个问题可以让员工庆祝甚至夸耀一些自己的成果,包括那些跟最高优先级不相干而被忽视的小事情.借此你也 ...
- python中pickle简介
2017-04-10 pickle是用来加工数据的,可以用来存取结构化数据. 例如: 一个字典a = {'name':'Timmy','age':26},用pickle.dump存到本地文件,所存数据 ...
- Android学习(十四) Service组件
一.定义 运行在后台,没有页面,不可见.优先级高于Activity,当系统内存不足时,会先释放一些Activity.注意,Service同样是运行在主线程中,不能做一些耗时操作.如果一定要做一些耗时的 ...
- 【转载】json对象的使用
使用JSON 进行数据传输 一.选择的意义 在异步应用程序中发送和接收信息时,可以选择以纯文本和 XML 作为数据格式.为了更好的使用ajax, 我们将学习一种有用的数据格式 JavaScript O ...
- LeetCode题目:Permutations
题目:Given a collection of distinct numbers, return all possible permutations. 大意:全排列给定数组,其中给定数组中没有相同的 ...
- C# 反编译工具
justdecompile http://down.51cto.com/data/2067031 ILSpy http://www.fishlee.net/soft/ilspy_chs/
- excel表格快捷键
CTRL+A 全选 CTRL+B 加粗 CTRL+C 复制 CTRL+D 下拉(复制上一个单元格的格式和内容) CTRL+G 定位 CTRL+F ...
- ClassLibary和WPF User Control LIbary和WPF Custom Control Libary的异同
说来惭愧,接触WPF这么长时间了,今天在写自定义控件时遇到一个问题:运行界面中并没有显示自定义控件,经调试发现原来没有加载Themes中的Generic.xaml. 可是为什么在其他solution中 ...
- Ubuntu Server 命令行下显示中文乱码(菱形)解决办法
如果Ubuntu Server在安装过程中,选择的是中文(很多新手都会在安装时选择中文,便于上手),这样在完成安装后,系统默认的语言将会是中文zh_CN.UTF- 8.但问题是我们安装的是服务器,只需 ...
- TCP是如何保证包的顺序传输
转自:http://blog.csdn.net/ggxxkkll/article/details/7894112 大家都知道,TCP提供了最可靠的数据传输,它给发送的每个数据包做顺序化(这看起来非常烦 ...