时间限制: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. consist of, made up of

    consist vi.由……组成:由……构成(常和介词of构成固定搭配)made up of由……组成[例如] One year consists of 365 days.一年有365天.The te ...

  2. ejs - 初试

    官方API: https://www.npmjs.com/package/ejs - 模板引擎 ejs文件(和普通html文件没什么区别,只是多增加了变量) <!DOCTYPE html> ...

  3. _.pick lodash

    http://lodash.think2011.net/pick _.pick(object, [props]) 创建一个从 object 中选中的属性的对象. 参数 object (Object) ...

  4. 【Django】其他项目导入到Pycharm无法使用,报错:Error: Django is not importable in this environment

    导入项目后如下:项目名称那出现一个小叉 点击启动后提示错误: 那是由于运行环境的路径没有指向python的安装路径,如下图即可解决问题

  5. zabbix监控第二块网卡是否连通

    配置zabbix客户端配置文件 vim /etc/zabbix/zabbix_agentd.conf 添加  Include=/etc/zabbix/zabbix_agentd.d/ 添加脚本检测网卡 ...

  6. [linux]top命令详解-实时显示系统中各个进程的资源占用状况

    简介 top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器. top显示系统当前的进程和其他状况,是一个动态显示过程,即可以通过用户按 ...

  7. 在Java中怎样高效的推断数组中是否包括某个元素

    来自 http://www.hollischuang.com/archives/1269? 怎样检查一个数组(无序)是否包括一个特定的值?这是一个在Java中经经常使用到的并且非常实用的操作.同一时候 ...

  8. [j2ee]java中的xml操作

    一.XML简单介绍      xml是可扩展标记语言,主要用来标记数据.定义数据类型,很适合万维网传输. xml特点: xml是一种标记语言.非常类似HTML xml的设计宗旨是数据传输,而不是显示数 ...

  9. smarty、smarty格式化、smarty整数、smarty float、smarty各种转换方式、smarty日期转换等等 (转)

    <? require("setup.php"); define('PAGETITLE','pagtitle'); function insert_top($lid,$sid) ...

  10. ppm\pgm格式

    PGM 是便携式灰度图像格式(portable graymap file format),在黑白超声图像系统中经常使用PGM格式的图像.文件的后缀名为".pgm". PGM格式图像 ...