/************************************************************************/
/* 题目1002:Grading
时间限制:1 秒
内存限制:32 兆
特殊判题:否 题目描述:
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:
P满分、T公差。
• 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.
·如果G1和G2的差小于公差,则取平均。
• If the difference exceeds T, the 3rd expert will give G3.
·如果G1和G2差大于公差,则看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.
·如果G3与G1或G2中一个差小于公差,则取G3及相近一成绩的平均。
• If G3 is within the tolerance with both G1 and G2,
then this problem's grade will be the maximum of the three grades.
·如果G3与G1、G2差均小于公差。则最终成绩取最大值。
• If G3 is within the tolerance with neither G1 nor G2,
a judge will give the final grade GJ.
·如果G3与G1、G2差值均大于公差,则由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 <iostream>
#include <iomanip>
using namespace std;
double sAbs(double x)
{
if(x>=)return x;
else return -x;
}
double max(double x, double y , double z)
{
return
(x>y)?
((x>z)?x:z)
:((y>z)?y:z);
}
int main()
{
double P,T,G1,G2,G3,GJ;
double temp,temp3,final;
bool isTwoLarger;
P = T = G1 = G2 = G3 = GJ = ;
isTwoLarger = false;
while(cin>>P>>T>>G1>>G2>>G3>>GJ)
{
if(T>P)cout<<"Data Error!"<<endl;
//((G1-G2)<=0)?(isTwoLarger = true):(isTwoLarger = false);
//if(isTwoLarger)temp = G2 - G1;
//else temp = G1 - G2;
//if(temp<=T)final = (G1+G2)/2.0;
//else if(isTwoLarger)
//{
// if(G3<=G1)
// if((G1-G3)>T)final = GJ;
// else final = (G3+G1)/2.0;
// else if(G3>G2)
// if((G3-G2)>T)final = GJ;
// else final = (G3+G2)/2.0;
// else
// {
// temp = G3-G1;
// temp3 = G2-G3;
// if((temp<=T)&&(temp3<=T))final = G2;
// else if((temp>T)&&(temp3>T))final = GJ;
// else if((temp3-temp)>0)
// final = (G3+G1)/2.0;
// else final = (G3+G2)/2.0;
// }
//}
//else
//{
// if(G3<=G2)
// if((G2-G3)>T)final = GJ;
// else final = (G3+G2)/2.0;
// else if(G3>G1)
// if((G3-G1)>T)final = GJ;
// else final = (G3+G1)/2.0;
// else
// {
// temp = G3-G2;
// temp3 = G1-G3;
// if((temp<=T)&&(temp3<=T))final = G1;
// else if((temp>T)&&(temp3>T))final = GJ;
// else if((temp3-temp)>0)
// final = (G3+G2)/2.0;
// else final = (G3+G1)/2.0;
// }
//}
if(sAbs(G1-G2)<=T)final = (G1+G2)/2.0;
else if((sAbs(G1-G3)<=T)&&(sAbs(G2-G3)<=T)) final = max(G1,G2,G3);
else if(sAbs(G2-G3)<=T) final = (G2+G3)/2.0;
else if(sAbs(G1-G3)<=T)final = (G1+G3)/2.0;
else final = GJ;
cout<<fixed<<::setprecision()<<final<<endl;
//printf("%.1f\n",final);
}
return ;
} //#include <iostream>
//#include <iomanip>
//#include <cmath>
//using namespace std;
//double getMax( double x, double y, double z)
//{
// return
// (x>y)?
// ((x>z)?x:z)
// :((y>z)?y:z);
//
//}
//int main()
//{
// double P,T,G1,G2,G3,GJ;
// double final;
// cin>>P>>T>>G1>>G2>>G3>>GJ;
// if(abs(G1-G2)<=T)
// {
// cout<<fixed<<::setprecision(1)<<(G1+G2)/2.0<<endl;
// }
// else if(abs(G3-G1)<=T&&abs(G3-G2)<=T)
// {
// cout<<fixed<<::setprecision(1)<<getMax(G1,G2,G3)<<endl;
// }
// else if(abs(G3-G2)<=T)
// {
// cout<<fixed<<::setprecision(1)<<(G3+G2)/2.0<<endl;
// }
// else if(abs(G3-G1)<=T)
// {
// cout<<fixed<<::setprecision(1)<<(G3+G1)/2.0<<endl;
// }
// else
// {
// cout<<fixed<<::setprecision(1)<<GJ<<endl;
// }
// return 0;
//
//}

_jobdu_1002的更多相关文章

随机推荐

  1. 转MYSQL学习(二) 运算符

    MYSQL中的运算符很多,这一节主要讲MYSQL中有的,而SQLSERVER没有的运算符 安全等于运算符(<=>) 这个操作符和=操作符执行相同的比较操作,不过<=>可以用来判 ...

  2. DisJSet:食物链(POJ 1182)

           动物王国的食物链 这一题有两种思路,先介绍第一种: 题目是中文的,我就不翻译了,也很好理解,就是一个A-B-C-A的一个循环的食物链,给定一些条件,问你哪些条件是错的 这一题,是一道比较 ...

  3. BestCoder12 1002.Help him(hdu 5059) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5059 题目意思:就是输入一行不多于 100 的字符串(除了'\n' 和 '\r' 的任意字符),问是否 ...

  4. Linux/Ubuntu下解压命令

    .tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) ——————————————— .gz 解压 ...

  5. jquery给height拼接动态变量

    var sizeLength = "${list.size()}"; if(sizeLength==''){ sizeLength=0; } sizeLength=400*size ...

  6. HDU 5317 RGCDQ (数论素筛)

    RGCDQ Time Limit: 3000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status ...

  7. LESS学习笔记1

    个人理解:less是一个可以写函数的css

  8. 工作空间项目不存在,eclipse中项目删不掉

    解决:E:\androidworkspaceall\.metadata\.plugins\org.eclipse.core.resources\.projects  ->删除对应项目

  9. CI框架获取post和get参数_CodeIgniter心得

    请参考:CI文档的输入类部分: $this->input->post() $this->input->get() ------------------------------- ...

  10. Xamarin.Android开发实践(十五)

    Xamarin.Android学习之应用程序首选项 一.前言 任何App都会存在设置界面,如果开发者利用普通控件并绑定监听事件保存设置,这 一过程会非常的枯燥,而且耗时.我们可以看到Android系统 ...