_jobdu_1002
/************************************************************************/
/* 题目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的更多相关文章
随机推荐
- C++类编程(一)const的使用
设计类时,考虑以下五点 1.构造函数初始化列表 2.函数该不该加const 3.参数传递尽量考虑用引用传递,考虑加不加const 4.返回用不用引用 5.数据尽量放在private,函数尽量放在pub ...
- spring3 + mybatis + maven:junit测试错误
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c ...
- XP 之后, Delphi 动注册表不方便了...逼出来一个办法:
XP 之后, Delphi 动注册表不方便了...逼出来一个办法: 手头的程序需要修改注册表, 以让当前程序成为某格式的默认打开程序并关联图标; Vista 之后需要管理员权限才能操作注册表, 很麻烦 ...
- ACdream 1188 Read Phone Number (字符串大模拟)
Read Phone Number Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Sub ...
- image warping
- Android之ScrollView
1.ScrollView和HorizontalScrollView是为控件或者布局添加滚动条 2.上述两个控件只能有一个孩子,但是它并不是传统意义上的容器 3.上述两个控件可以互相嵌套 4.滚动条的位 ...
- Java IO流系统整理
Java IO流的分类 Java中的流,可以从不同的角度进行分类. 按流向分类: 输入流: 程序可以从中读取数据的流.输出流: 程序能向其中写入数据的流. 按数据传输单位分类: 字节流:以字节(8位二 ...
- Xamarin.Android开发实践(七)
Xamarin.Android广播接收器与绑定服务 一.前言 学习了前面的活动与服务后,你会发现服务对于活动而言似乎就是透明的,相反活动对于服务也是透明的,所以我们还需要一中机制能够将服务和活动之间架 ...
- hdu 1166 线段树单点更新
等线段树复习完再做个总结 1101 2 3 4 5 6 7 8 9 10Query 1 3Add 3 6Query 2 7Sub 10 2Add 6 3Query 3 10End Case 1:633 ...
- Effective C++笔记:资源管理
资源:动态分配的内存.文件描述器.互斥锁.图形界面中的字型与笔刷.数据库连接以及网络sockets等,无论哪一种资源,重要的是,当你不再使用它时,必须将它还给系统. 条款13:以对象管理资源 当我们向 ...