题目描述:

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

code

#include <bits/stdc++.h>using namespace std ;int main (){int P ,T , G1,G2,G3,GJ;float grade ;while (cin>>P>>T>>G1>>G2>>G3>>GJ){if (abs(G1-G2)<=T){grade =  1.0*(G1+G2)/2;}else {if (abs(G1-G3)<=T && abs(G2-G3)<=T){grade = max(G1,max(G2,G3));}else if (abs(G1-G3)<=T){grade = 1.0*(G1+G3)/2 ;}else if (abs(G2-G3)<=T){grade = 1.0*(G2+G3)/2 ;}else {grade = GJ;}}printf("%.1f\n",grade);}return 0;
}

题目1002:Grading相关推荐

  1. PAT乙级题目——1002写出这个数

    问题分析:1.数据比较大,并且输入数据时没有停顿,所有使用字符串来存储数据 string str=""; cin>>str; 2.使用字符串数组来存储每个数字的拼音 s ...

  2. python post与get的区别_Python Requests库 Get和Post的区别和Http常见状态码

    (1)   在客户端,Get方式在通过URL提交数据,数据在URL中可以看到:POST方式,数据放置在HTML HEADER内提交. (2)   GET方式提交的数据最多只能有1024 Byte,而P ...

  3. python中变量名后的逗号_深入浅析python变量加逗号,的含义

    逗号,用于生成一个长度为1的元组 >>> (1) 1 >>> (1,) (1,) >>> 1, (1,) 因此需要将长度为1的元组中元素提取出来可 ...

  4. 【C语言网】C语言基础题集训练详解(一)

    [C语言网]基础题集训练详解(一) 题目目录 [C语言网]基础题集训练详解(一) 前言 一.题目1000 [竞赛入门]简单的a+b 二. 题目1001 [编程入门]第一个HelloWorld程序 三. ...

  5. 2022“杭电杯”中国大学生算法设计超级联赛 (1) 杭电多校第一场 2 3 4 5 8 12

    题目 1002 Dragon slayer 标程 1003 Backpack AC代码 1004 Ball AC代码 1008 Path AC代码 1009 Laser AC代码 1012 Alice ...

  6. 「PAT甲级真题解析」Advanced Level 1009 Product of Polynomials

    PAT (Advanced Level) Practice 1009 Product of Polynomials 如果对你有帮助,要点个赞让我知道喔~ 文章目录 问题分析 完整步骤描述 伪代码描述 ...

  7. 杭电OJ 1002 题目解答

    HDOJ 1002 A+B Problem Ⅱ AC 代码: #include <iostream> #include <string> #include <algori ...

  8. HOJ题目分类//放这儿没事刷刷学算法!嘻嘻!

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  9. 力扣1002.查找常用字符

    力扣 1002. 查找常用字符 本人力扣练习已上传至码云,可互相学习借鉴. 难度-简单 题目: 给定仅有小写字母组成的字符串数组 A,返回列表中的每个字符串中都显示的全部字符(包括重复字符)组成的列表 ...

最新文章

  1. Hyperledger Fabric 私有数据(1)概念
  2. linux汇编stdin,汇编:从标准输入中读取整数,将其递增并打印到标准输出
  3. 2场直播丨MySQL 数据库最常见的 6 类故障的排除方法、2020数据技术嘉年华·金融峰会暨数据库大咖讲坛(第4期)...
  4. c#调用带有安全认证的java webservice
  5. 顺序表之元素位置互换(改进版)
  6. keybd_event()使用方法
  7. (github精选)优秀的openSCAD项目image2surface
  8. Apache Flink 官方文档--流(DataStream API)-旁路输出
  9. Pandas DataFrame 函数应用和映射
  10. python和大数据的关系_Java大数据和python大数据哪个更主流?
  11. 大数据使用的5种主要数据挖掘技术
  12. Java实现字符串逆序输出
  13. 营收同比增长13.55%  领跑ICT的中天科技为何跌了?
  14. Spring Boot中多个PostConstruct注解执行顺序控制
  15. logstash集成elasticsearch报错: Attempted to resurrect connection to dead ES instance
  16. 论文笔记:Object Detection in 20 Years: A Surve(目标检测20年研究综述)
  17. Excel无法vlookup事件
  18. 【强烈推荐】机器学习之算法篇
  19. python装饰器特性iy雾_Python高级特性: 12步轻松搞定Python装饰器
  20. CDMA手机鉴权的过程说明

热门文章

  1. 有时候,996确实会让你麻木
  2. 再见,余!额!宝!!!
  3. 为什么普通红包自己不能领_我的拼多多不能领红包是怎么回事呢?
  4. 期刊 | 人类遗传学领域期刊速览
  5. 学术谱系树:来看看你导师的师承
  6. NOI入门级:数据结构之线性表
  7. linux django 指定端口,linux部署django项目流程(全)
  8. ubuntu c++检测usb口事件变化_炼就“火眼金睛”,FETA40i-C核心板“牵手”光时域反射仪...
  9. Java工作笔记-发送SOAP协议请求
  10. Linux工作笔记-RabbitMQ的安装