九度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. ...
随机推荐
- ElasticSearch 结构化搜索
1.介绍 结构化搜索(Structured search) 是指有关探询那些具有内在结构数据的过程.比如日期.时间和数字都是结构化的:它们有精确的格式,我们可以对这些格式进行逻辑操作. 比较常见的操作 ...
- 数据库字段名称转java字段名称
/** * * @Title: changeToJavaFiled * @Description: TODO(将数据库中带下划线的字段转换为Java常用的驼峰字段) * @param @param f ...
- SparkMLlib聚类学习之KMeans聚类
SparkMLlib聚类学习之KMeans聚类 (一),KMeans聚类 k均值算法的计算过程非常直观: 1.从D中随机取k个元素,作为k个簇的各自的中心. 2.分别计算剩下的元素到k个簇中心的相异度 ...
- hdu 1030 Delta-wave(数学题+找规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1030 Delta-wave Time Limit: 2000/1000 MS (Java/Others ...
- Python类定义和类继承详解
类实例化后,可以使用其属性,实际上,创建一个实例之后,可以通过类名访问其属性,如果直接使用类名修改其属性,那么直接影响已经实例化的对象. 类的私有属性: __private_attrs 两个下划线开头 ...
- mysql 杀掉(kill) lock进程脚本
杀掉lock进程最快的方法是重启mysql,像你这种情况,1000多sql锁住了,最好是重启如果不允许重启,我提供一个shell脚本,生成 kill id命令杀掉lock线程,如下:--------- ...
- 如何创建JAR文件?如何运行.jar形式的Java程序?
一.如何创建JAR文件? .jar是用来压缩档案或者解压档案的文件格式,其特点是具有无损压缩的功能.想知道如何创建这种程序?请访问 http://www.cnblogs.com/yjmyzz/p/ex ...
- HTTP协议断点续传
using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;usi ...
- 了解MVC框架开发
版权声明:本文为博主原创文章,未经博主允许不得转载. 前言:本篇文章我们浅谈下MVC各个部分,模型(model)-视图(view)-控制器(controller), 以及路由. 对于使用MVC的好处大 ...
- 12个高效的VS调试技巧
介绍 调试是软件开发周期中的一个很重要的部分,有时很有挑战性,有时候则让程序员迷惑,有时候让程序员发疯,但是.可以肯定的是,对于任何不是太那个微不足道的程序来说,调试是不可避免的.近年来,调试工具的发 ...