时间限制: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
来源:
2011年浙江大学计算机及软件工程研究生机试真题

思路:

基本的单个数据处理题,主要考察分支判断代码撰写。

代码:

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

  1. 九度oj 1002 Grading 2011年浙江大学计算机及软件工程研究生机试真题

    #include<iostream> #include<queue> #include<cstdio> #include<cstring> #inclu ...

  2. 九度oj题目1002:Grading

    //不是说C语言就是C++的子集么,为毛printf在九度OJ上不能通过编译,abs还不支持参数为整型的abs()重载 //C++比较正确的做法是#include<cmath.h>,cou ...

  3. hdu 1284 关于钱币兑换的一系列问题 九度oj 题目1408:吃豆机器人

    钱币兑换问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  4. 【九度OJ】题目1176:树查找 解题报告

    [九度OJ]题目1176:树查找 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1176 题目描述: 有一棵树,输出某一深度的所有节点 ...

  5. 【九度OJ】题目1445:How Many Tables 解题报告

    [九度OJ]题目1445:How Many Tables 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1445 题目描述: ...

  6. 【九度OJ】题目1109:连通图 解题报告

    [九度OJ]题目1109:连通图 解题报告 标签(空格分隔): 九度OJ 原题地址:http://ac.jobdu.com/problem.php?pid=1109 题目描述: 给定一个无向图和其中的 ...

  7. 九度oj 题目1087:约数的个数

    题目链接:http://ac.jobdu.com/problem.php?pid=1087 题目描述: 输入n个整数,依次输出每个数的约数的个数 输入: 输入的第一行为N,即数组的个数(N<=1 ...

  8. 九度OJ 1502 最大值最小化(JAVA)

    题目1502:最大值最小化(二分答案) 九度OJ Java import java.util.Scanner; public class Main { public static int max(in ...

  9. 九度OJ,题目1089:数字反转

    题目描述: 12翻一下是21,34翻一下是43,12+34是46,46翻一下是64,现在又任意两个正整数,问他们两个数反转的和是否等于两个数的和的反转. 输入: 第一行一个正整数表示测试数据的个数n. ...

随机推荐

  1. 最长公共字串算法, 文本比较算法, longest common subsequence(LCS) algorithm

    ''' merge two configure files, basic file is aFile insert the added content of bFile compare to aFil ...

  2. asp.net自制分页页码条控件

    用过微软的服务器控件分页的人都知道~那卡的一A啊~ 遂想自制分页页码条控件以备不时之需. 走你~ public static class PageShow { /// <summary> ...

  3. Windows服务器SYSTEM权限Webshell无法添加3389账户情况突破总结

    转自:http://bbs.blackbap.org/thread-2331-1-1.html 近好多Silic的朋友在Windows下SYSTEM权限的php webshell下添加账户,但是却无法 ...

  4. JavaScript对象浅复制

    1.概述 Object.assign方法用于对象的合并,将源对象(source)的所有可枚举属性,复制到目标对象(target). 注意,如果目标对象与源对象有同名属性,或多个源对象有同名属性,则后面 ...

  5. STL学习笔记(移除性算法)

    本节所列的算法是根据元素值或某一准则,在一个区间内移除某些元素. 这些算法并不能改变元素的数量,它们只是将原本置于后面的“不移除元素”向前移动,覆盖那些被移除的元素. 这些算法都返回逻辑上的新终点 移 ...

  6. 正则表达式Pattern ,Matcher

    正则表达式:符合一定规则的表达式 作用:用于专门操作字符串 特点:用于一些特定的符号来表示一些代码的操作,这样就简化代码的书写 学习正则表达式就是要学习一些特殊符号的使用 好处:简化对字符串复杂的操作 ...

  7. hdu 神、上帝以及老天爷 java

    问题: 递推.可是a[i]=(a[i-1]+a[i-2])+(i-1)公式没有推出来. 在递推时,for循环约束值用的输入的m导致数组没有储存数. 在算阶乘时for循环中将i和j用混了,导致没有数输出 ...

  8. 我是怎样理解web页面的

    事实上web页面包括三部分东东 1.页面展示的元素(HTML) 2.页面元素展示的样式(CSS) 3.控制页面元素的交互(JavaScript) 不管页面多么复杂,从这三方面去看,都会得到清晰的认识的 ...

  9. .net 定时服务

    namespace MvcApplication1 { public class MvcApplication : System.Web.HttpApplication { protected voi ...

  10. JQuery find函数选择器使用