九度题目1002:Grading
来源:互联网 发布:淘宝网商品域名 编辑:程序博客网 时间:2024/05/22 10:39
May 16, 2016
作者:dengshuai_super
出处:http://blog.csdn.net/dengshuai_super/article/details/51425105
声明:自由转载,转载请注明作者及出处。
题目1002:Grading
题目描述:
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
题目分析:
输入为6个参数:P, T, G1, G2, G3, and GJ ,全部的成绩都满足在[0, P]区间内。
分级规则:
•问题将首先被分配到2个专家,得到G1和G2。如果差异是可以接受的,也就是满足|G1 - G2| ≤ T,这一问题的成绩将取G1和G2的平均值。
•如果差异超过T,第三专家将给G3。
•如果G3和G1或G2的差值只有其中一个在公差范围内,那么这个问题的成绩将取G3和最接近的成绩的平均值。
•如果G3和G1或G2的差值都在公差范围内,那么这一问题的成绩将取G1,G2,G3的最大值。
•如果没有G3和G1 或G2的差值都不在的公差范围内,将作出最后的等级GJ。
代码如下:
/****************************************************************************** 九度题目1002:Grading ******************************************************************************* by Deng shuai May 16 2016* http://blog.csdn.net/dengshuai_super******************************************************************************* Copyright (c) 2016, Deng Shuai* All rights reserved.*****************************************************************************/
#include<stdio.h>#include<stdlib.h>#include<math.h>//#include<time.h>int P,T,G1,G2,G3,GJ;double my_max(double x,double y){ return x>y?x:y;}int main(int argc, char *argv[]){ //clock_t start, end; //start = clock(); //记录开始时间 while(scanf("%d %d %d %d %d %d",&P,&T,&G1,&G2,&G3,&GJ)!=EOF) { if((G1>P||G1<0)||(G2>P||G2<0)||(G3>P||G3<0)||(GJ>P||GJ<0)) { break; } if(abs(G1-G2)<=T) printf("%.1lf\n",(double)(G1+G2)/2.0); else if(abs(G1-G3)<=T&&abs(G2-G3)<=T) printf("%.1lf\n",my_max(my_max(G1,G2), G3)); else if(abs(G1-G3)>T&&abs(G2-G3)>T) printf("%.1lf\n",(double)GJ); else if(abs(G1-G3)<=T&&abs(G2-G3)>T) printf("%.1lf\n",((double)(G3+G1))/2.0); else if(abs(G2-G3)<=T&&abs(G1-G3)>T) printf("%.1lf\n",((double)(G3+G2))/2.0); //end = clock(); //结束时间 //printf("spend %lf s",(double)(end - start) / CLOCKS_PER_SEC); } return 0;}
截图:
0 0
- 九度 题目1002:Grading
- 【九度】题目1002:Grading
- 九度 题目1002:Grading
- 九度题目1002:Grading
- 九度——题目1002:Grading
- 九度OJ 题目1002:Grading
- 九度oj题目1002:Grading
- 九度online:题目1002:Grading
- 九度OJ 题目1002:Grading
- 九度OJ题目1002:Grading
- 九度1002 Grading
- 九度1002 Grading
- 九度OJ 1002 Grading
- 九度OJ 1002:grading
- 九度 OJ 1002 grading
- 九度OJ 1002 Grading
- 【九度OJ--1002】grading
- 九度OJ 1002:Grading
- 安装GITHUB错误解决
- 企业开发者账号苹果官方链接:
- 好
- extern ''C'' 的 学习浅谈
- ajax登录过期跳转
- 九度题目1002:Grading
- STROM state persist操作的基本理解
- game design原理系列学习笔记(三)
- C语言笔记(三)
- * daemon not running. starting it now on port 5037 *
- UNICODE与ANSI的区别
- NSOperation中指定异步任务的依赖关系
- C语言笔记(四)
- Oracle 登录命令