/************************************************************************/
/* 题目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. for循环,pydev提示未使用的变量,解决办法

    对于如下代码,pvdev会产生未使用变量的警告 for i in range(5): func() 解决办法: 把变量替换成下划线_,就不会生产告警了.改变后如下: for _ in range(5) ...

  2. Android PullToRefreshListView上拉刷新和下拉刷新

    PullToRefreshListView实现上拉和下拉刷新有两个步骤: 1.设置刷新方式 pullToRefreshView.setMode(PullToRefreshBase.Mode.BOTH) ...

  3. Android Volley获取json格式的数据

    为了让Android能够快速地访问网络和解析通用的数据格式Google专门推出了Volley库,用于Android系统的网络传输.volley库可以方便地获取远程服务器的图片.字符串.json对象和j ...

  4. BestCoder17 1002.Select(hdu 5101) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5101 题目意思:给出 n 个 classes 和 Dudu 的 IQ(为k),每个classes 都有 ...

  5. 【好用的小技巧】win8兼容、网页不让复制

    1.今天下了个matlab7,我用的是win8系统,不兼容. 解决:鼠标右键matlab7的快捷键,点击属性,选择兼容性,选择window vista即可运行 2.在一个 网页上看到一个对自己很有帮助 ...

  6. git revert 用法

    git revert 撤销 某次操作,此次操作之前和之后的commit和history都会保留,并且把这次撤销作为一次最新的提交    * git revert HEAD                ...

  7. Android之数据库操作

    安卓数据库帮助类 /** * 数据库帮助类,用于管理数据库 * @author Administrator * */ public class PersonSQLiteOpenHelper exten ...

  8. Rap 安装和配置

    本机环境 系统:CentOS 6.7 64 位 MySQL 5.6 JDK 1.8 Tomcat 8 Redis 3.0.7 Rap 0.14.1 Rap 说明 官网:https://github.c ...

  9. jquery.validate.unobtrusive.js插件作用

    在 ASP.NET MVC 中启用 Unobtrusive JavaScript 功能,可以在运行时由服务器端根据Model中设置的验证规则,自动生成客户端验证js代码(结合jquery.valida ...

  10. Libsvm自定义核函数【转】

    1. 使用libsvm工具箱时,可以指定使用工具箱自带的一些核函数(-t参数),主要有: -t kernel_type : set type of kernel function (default 2 ...