时间限制: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. golang sync.Cond 类

    众所周知,go语言在多线程方面的支持是十分完备的.在go语言sync包中提供了一个Cond类,这个类用于goroutine之间进行协作. 这个类并不复杂,只有三个函数,Broadcast() , Si ...

  2. 我的MAC可能在设置环境变量的时候设置错了,现在整个MAC的vi,ls等命令都执行不了了。

    1,在命令行中输入export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin这样可以保证命令行命令暂时可以使用.命令执行完之后先不要关闭终端或者c ...

  3. ECSHOP热门搜索关键词随机显示

    实现ECSHOP热门搜索关键词随机显示,需要修改ECSHOP模板和ECShOP程序,按照步骤修改即可. 一.打开 include/lib_main.php 文件,找到下面这段代码,删除之(大概在165 ...

  4. 2017.6.29 java读取.properties配置文件的几种方法

    参考来自:http://www.cnblogs.com/s3189454231s/p/5626557.html 关于路径的解释:http://blog.csdn.net/bluishglc/artic ...

  5. MyEclipse导入Hibernate出现Path must include project and resource;/project name

    如图,在MyEclipse 2014以下版本中都没遇见这个问题. 在导入Hibernate框架的时候,可以说真的随缘,运气不好,明明配置全都没问题,还是连续几次失败,这个时候除了烧高香拜拜,也只能靠百 ...

  6. spring 国际化-i18n

    i18n(其 来源是英文单词 internationalization的首末字符i和n,18为中间的字符数)是“国际化”的简称.在资讯领域,国际化(i18n)指让产品(出版 物,软件,硬件等)无需做大 ...

  7. 高效抽取loading,再多的载入页面也不怕

    当今的app基本上有两个操作,一个是载入数据 ,一个就是把数据显示到页面上.但假设页面特别的多.就每一个页面都要载入数据,就要写 loading 页面.我之前就是用dialog写,抽取出来一个类.哪里 ...

  8. angularjs事件传递$on、$emit和$broadcast

    如何在作用域之间通信呢? 1.创建一个单例服务,然后通过这个服务处理所有子作用域的通信. 2.通过作用域中的事件处理通信.但是这种方法有一些限制:例如,你并不能广泛的将事件传播到所有监控的作用域中.你 ...

  9. Android IntentService全然解析 当Service遇到Handler

    转载请标明出处: http://blog.csdn.net/lmj623565791/article/details/47143563: 本文出自:[张鸿洋的博客] 一 概述 大家都清楚.在Andro ...

  10. linux命令的别名alias,unalias

    1. 别名 linux别名alias的作用: 1. 简化特别长得命令和參数 2. 对一些命令添加默认选项.提高安全性. 2. alias使用 [www@work sh]$ alias lm='ls - ...