【九度OJ】1002:Grading
来源:互联网 发布:linux中usermod 编辑:程序博客网 时间:2024/05/02 10:16
地址:
http://ac.jobdu.com/problem.php?pid=1002
题目描述:
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.
输入:
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>float p, t, g1, g2, g3, gj;float grade;float ABS( float x ){ //求绝对值 if( x > 0 ){ return x; } else { return -x; }}int main(){ while( scanf( "%f %f %f %f %f %f", &p, &t, &g1, &g2, &g3, &gj) != EOF ){ if( g1 - g2 <= t && g1 - g2 >= -t ){ //g1给的分数和g2给的分数在可接受范围 grade = (g1+g2)/2; printf( "%.1f\n", grade ); continue; } else if( g3 - g1 <= t && g3 - g1 >= -t && g3 - g2 <= t && g3 - g2 >= -t ){ //g3给的分数和g1g2给的分数均在可接受范围内 float maxmum = g1 > g2 ? g1 : g2; maxmum = maxmum > g3 ? maxmum : g3; //找出三个中分数最大的那个 grade = maxmum; printf( "%.1f\n", maxmum ); continue; } else if( (g3 - g1 <= t && g3 - g1 >= -t) || (g3 - g2 <= t && g3 - g2 >= -t) ){ //g3给的分数和g1或者g2给的分数在可接受范围内(去除同时可在接受范围内的情况) float g3g1 = ABS( g3 - g1 ); float g3g2 = ABS( g3 - g2 ); if( g3g1 > g3g2 ){ grade = (g3+g2)/2; printf( "%.1f\n", grade ); continue; } else{ grade = (g3+g1)/2; printf( "%.1f\n", grade ); continue; } } else{ //g3给的分数和g1或者g2给的均分数在可接受范围内 grade = gj; printf( "%.1f\n", grade ); continue; } }}/************************************************************** Problem: 1002 User: 螺小旋 Language: C++ Result: Accepted Time:0 ms Memory:1020 kb****************************************************************/
- 九度OJ 1002 Grading
- 九度OJ 1002:grading
- 九度 OJ 1002 grading
- 九度OJ 1002 Grading
- 【九度OJ--1002】grading
- 九度OJ 1002:Grading
- 九度oj-1002-Grading
- 九度 OJ 1002:Grading
- 九度OJ 1002 Grading
- 九度OJ-1002:Grading
- 九度OJ 1002 Grading
- 【九度OJ】1002:Grading
- 九度OJ 题目1002:Grading
- 九度oj题目1002:Grading
- 九度OJ 题目1002:Grading
- 九度OJ题目1002:Grading
- 九度1002 Grading
- 九度1002 Grading
- Clion this file does not belong to any project target问题解决方案
- select源码剖析
- javascript学习笔记之BOM和DOM详解
- [C++] 前置++和后置++的区别
- unity 通过代码查找一个文件夹下的所有文件
- 【九度OJ】1002:Grading
- 《Redis源码学习笔记》键过期
- appium python-client代码分析(一)
- 设计模式之单例模式
- 添加:TK_FLASH_INFO_AVAILABLE_TRUE的metadata 否则没有手电筒功能
- 回文数-lintcode-c++
- POJ1730 Perfect Pth Powers (math)
- iOS学习笔记-104.多线程03——线程间通信图片下载与时间计算
- 函数重载(overload)、函数覆盖(override)与隐藏