九度OJ:1002-Grading
时间限制:1 秒内存限制:32 兆特殊判题:否提交:24102解决:6126
题目描述:
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>
#include<math.h>
using namespace std;
int main()
{
int p=0,t=0,g1=0,g2=0,g3=0,g4=0;
int a,b,max;
float g;
while(scanf("%d %d %d %d %d %d",&p,&t,&g1,&g2,&g3,&g4)!=EOF){
if(abs(g1-g2) <= t){
g=(float)(g1+g2)/2;
}
else if(abs(g1-g3)<=t || abs(g2-g3)<=t)
{
a=abs(g1-g3);
b=abs(g2-g3);
if(a<t && b<t)
{
max=g1;
if(g2>max){
max=g2;
}
if(g3>max){
max=g3;
}
g=(float)max;
}
else if(a<b){
g=(float)(g1+g3)/2;
}
else{
g=(float)(g2+g3)/2;
}
}
else{
g=(float)g4;
}
printf("%.1f\n",g);
}
# return 0;
}`
结果:
- 输出文件名: D:\DevC++\程序\two.exe
- 输出大小: 362.3271484375 KiB
- 编译时间: 0.45s
注意点:输入是有多组数据的。
九度OJ:1002-Grading的更多相关文章
- 九度oj 1002 Grading 2011年浙江大学计算机及软件工程研究生机试真题
#include<iostream> #include<queue> #include<cstdio> #include<cstring> #inclu ...
- 九度OJ 1002:Grading
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:18410 解决:4753 题目描述: Grading hundreds of thousands of Graduate Entrance ...
- 九度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. ...
随机推荐
- 从点击到呈现 — 详解一次HTTP请求
一般来说,很多的参考资料上面都会说,http 是一个基于请求/响应的工作模式,然后画出一张浏览器和服务器的 b/s 结构图,再画上两个箭头,表示请求和响应,应该说这么解释是易懂的,一般也是够清楚的,但 ...
- JavaScript面向对象编程—this详解
this详解 作者的话 在JavaScriptOPPt面向对象编程中,this这位老大哥,相信大家不会陌生.大家在遇到this时,很多朋友难免会有个疑问:"这个this是什么,它到底指向 ...
- Docker- 创建支持SSH服务的容器镜像
示例 - CentOS7 [root@CentOS-7 ~]# cat ssh-centos7 FROM centos:centos7 MAINTAINER anliven "anliven ...
- JavaScript面向对象的理解
JavaScript面向对象的理解 笔记链接: http://pan.baidu.com/s/1c0hivuS 1:JavaScript 中分两种对象,函数对象和普通对象new Function() ...
- C返回函数指针的函数
如下函数 char (*retCharWithInt(char, char))(int); 申明了函数指针retCharWithInt,该指针指向一个形参是(char,char),返回值是char(* ...
- 深入理解IOC
1. IoC理论的背景 我们都知道,在采用面向对象方法设计的软件系统中,它的底层实现都是由N个对象组成的,所有的对象通过彼此的合作,最终实现系统的业务逻辑. 图1:软件系统中耦合的对象 如果我们打开机 ...
- struts2.5能不能再恶心点
Caused by: java.lang.IllegalArgumentException: unknown reserved key '_typeConverter' at ognl.OgnlCon ...
- XML文件生成——借助JDOM
import java.io.* ; import org.jdom.* ; import org.jdom.output.* ; public class DOMDemo { public stat ...
- SQL SERVER大话存储结构(6)_数据库数据文件
数据库文件有两大类:数据文件跟日志文件,每一个数据库至少各有一个数据文件或者日志文件,数据文件用来存储数据,日志文件用来存储数据库的事务修改情况,可用于恢复数据库使用. 这里分 ...
- Python中的模块介绍和使用
在Python中有一个概念叫做模块(module),这个和C语言中的头文件以及Java中的包很类似,比如在Python中要调用sqrt函数,必须用import关键字引入math这个模块,下面就来了解一 ...