九度OJ 1002 Grading

题目1002:Grading

时间限制:1 秒

内存限制:32 兆

特殊判题:否

提交:15686

解决:4053

题目描述:

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>
int P,T,G1,G2,G3,GJ;
int my_max(int x,int y)
{
    return x>y?x:y;
}
int main(int argc, char *argv[])
{
    while(scanf("%d %d %d %d %d %d",&P,&T,&G1,&G2,&G3,&GJ)!=EOF)
    {
        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);
    }
    return 0;
}

/**************************************************************
    Problem: 1002
    User: kirchhoff
    Language: C
    Result: Accepted
    Time:0 ms
    Memory:912 kb
****************************************************************/
时间: 2024-08-10 23:30:39

九度OJ 1002 Grading的相关文章

九度oj 1002 Grading 2011年浙江大学计算机及软件工程研究生机试真题

1 #include<iostream> 2 #include<queue> 3 #include<cstdio> 4 #include<cstring> 5 #include<cmath> 6 #include<algorithm> 7 using namespace std; 8 int map[15][15]; 9 int main(){ 10 int P,T,G1,G2,G3,GJ; 11 while(cin>>P

九度oj 题目1007:奥运排序问题

九度oj 题目1007:奥运排序问题   恢复 题目描述: 按要求,给国家进行排名. 输入:                        有多组数据. 第一行给出国家数N,要求排名的国家数M,国家号从0到N-1. 第二行开始的N行给定国家或地区的奥运金牌数,奖牌数,人口数(百万). 接下来一行给出M个国家号. 输出:                        排序有4种方式: 金牌总数 奖牌总数 金牌人口比例 奖牌人口比例 对每个国家给出最佳排名排名方式 和 最终排名 格式为: 排名:排名

[ACM] 九度OJ 合唱队形 (最长递增子序列改版)

题目1131:合唱队形 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1680 解决:520 题目描述: N位同学站成一排,音乐老师要请其中的(N-K)位同学出列,使得剩下的K位同学不交换位置就能排成合唱队形. 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1, 2, -, K,他们的身高分别为T1, T2, -, TK, 则他们的身高满足T1 < T2 < - < Ti , Ti > Ti+1 > - > TK (1 <= i <=

[ACM] 九度OJ 1553 时钟

时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:1733 解决:656 题目描述: 如图,给定任意时刻,求时针和分针的夹角(劣弧所对应的角). 输入: 输入包含多组测试数据,每组测试数据由一个按hh:mm表示的时刻组成. 输出: 对于每组测试数据,输出一个浮点数,代表时针和分针的夹角(劣弧对应的角),用角度表示,结果保留两位小数. 样例输入: 03:00 14:45 样例输出: 90.00 172.50 来源: 2014年王道论坛计算机考研机试全真模拟考试 解题思路: 求时针和分针的

九度oj 题目1546:迷宫问题 (概率dp guess消元)

题目链接:点击打开链接 题目描述: 给定一个n*m的迷宫,如 S.. ..# E.E 其中,S代表开始位置,#代表不可行走的墙,E代表出口. 主人公从开始位置出发,每次等概率的随机选择下一个可以行走的位置,直到到达某一个出口为止. 现在他想知道,在这一概率事件中,它从开始位置走到某一个出口的期望步数是多少. 输入: 输入包含多组测试用例,每组测试用例由两个整数n,m(1<=n,m<=15)开始,代表迷宫的大小 接下去n行每行m个字符描述迷宫信息,具体规则如题面所述. 数据保证至少存在一个E和一

[九度OJ]货币问题,解题报告

题目 题目描述: 已知有面值为1元,2元,5元,10元,20元,50元,100元的货币若干(可认为无穷多),需支付价格为x的物品,并需要恰好支付,即没有找零产生. 求,至少需要几张货币才能完成支付. 如,若支付价格为12元的物品,最少需要一张10元和一张2元,即两张货币就可完成支付. 输入: 输入包含多组测试数据,每组仅包含一个整数p(1<=p<=100000000),为需支付的物品价格. 输出: 对于每组输入数据,输出仅一个整数,代表最少需要的货币张数. 样例输入: 10 11 13 样例输

九度oj题目1009:二叉搜索树

题目描述: 判断两序列是否为同一二叉搜索树序列 输入:                        开始一个数n,(1<=n<=20) 表示有n个需要判断,n= 0 的时候输入结束. 接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树. 接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树. 输出:                        如果序列相同则输出YES,否则输出NO 样

九度OJ&amp;北邮机试题题解(北邮2010网院)

题目一.九度OJ-1173:查找(水题随便搞) ac.jobdu.com/problem.php?pid=1173 题目描述: 输入数组长度 n 输入数组      a[1...n] 输入查找个数m 输入查找数字b[1...m] 输出 YES or NO  查找有则YES 否则NO . 输入: 输入有多组数据. 每组输入n,然后输入n个整数,再输入m,然后再输入m个整数(1<=m<=n<=100). 输出: 如果在n个数组中输出YES否则输出NO. 样例输入: 5 1 5 2 4 3 3

九度OJ&amp;北邮机试题(2010计算机)

题目一.九度OJ-1169:比较奇偶数个数 http://ac.jobdu.com/problem.php?pid=1169 题目描述: 第一行输入一个数,为n,第二行输入n个数,这n个数中,如果偶数比奇数多,输出NO,否则输出YES. 输入: 输入有多组数据. 每组输入n,然后输入n个整数(1<=n<=1000). 输出: 如果偶数比奇数多,输出NO,否则输出YES. 样例输入: 5 1 5 2 4 3 样例输出: YES 直接来代码: AC代码: /** *@xiaoran */ #inc