• _jobdu_1002


      1 /************************************************************************/
      2 /* 题目1002:Grading
      3     时间限制:1 秒
      4     内存限制:32 兆
      5     特殊判题:否
      6 
      7     题目描述:
      8     Grading hundreds of thousands of Graduate Entrance Exams is a hard work. 
      9     It is even harder to design a process to make the results as fair as possible. 
     10     One way is to assign each exam problem to 3 independent experts.
     11     If they do not agree to each other,
     12     a judge is invited to make the final decision.
     13     Now you are asked to write a program to help this process.
     14     For each problem, there is a full-mark P and a tolerance T(<P) given. 
     15     The grading rules are:
     16     P满分、T公差。
     17     • A problem will first be assigned to 2 experts, to obtain G1 and G2.
     18     If the difference is within the tolerance, 
     19     that is, if |G1 - G2| ≤ T, 
     20     this problem's grade will be the average of G1 and G2.
     21     ·如果G1和G2的差小于公差,则取平均。
     22     • If the difference exceeds T, the 3rd expert will give G3.
     23     ·如果G1和G2差大于公差,则看G3.
     24     • If G3 is within the tolerance with either G1 or G2, but NOT both, 
     25     then this problem's grade will be the average of G3 and the closest grade.
     26     ·如果G3与G1或G2中一个差小于公差,则取G3及相近一成绩的平均。
     27     • If G3 is within the tolerance with both G1 and G2,
     28     then this problem's grade will be the maximum of the three grades.
     29     ·如果G3与G1、G2差均小于公差。则最终成绩取最大值。
     30     • If G3 is within the tolerance with neither G1 nor G2, 
     31     a judge will give the final grade GJ.
     32     ·如果G3与G1、G2差值均大于公差,则由GJ决定最终成绩。
     33     输入:
     34     Each input file may contain more than one test case.
     35     Each case occupies a line containing six positive integers: 
     36     P, T, G1, G2, G3, and GJ, as described in the problem.
     37     It is guaranteed that all the grades are valid,
     38     that is, in the interval [0, P].
     39     输出:
     40     For each test case you should output the final grade of the problem in a line.
     41     The answer must be accurate to 1 decimal place.
     42     样例输入:
     43     20 2 15 13 10 18
     44     样例输出:
     45     14.0
     46 */
     47 /************************************************************************/
     48 
     49 #include <iostream>
     50 #include <iomanip>
     51 using namespace std;
     52 double sAbs(double x)
     53 {
     54     if(x>=0)return x;
     55     else return -x;
     56 }
     57 double max(double x, double y , double z)
     58 {
     59     return
     60     (x>y)?
     61         ((x>z)?x:z)
     62         :((y>z)?y:z);
     63 }
     64 int main()
     65 {
     66     double P,T,G1,G2,G3,GJ;
     67     double temp,temp3,final;
     68     bool   isTwoLarger;
     69     P = T = G1 = G2 = G3 = GJ = 0;
     70     isTwoLarger = false;
     71     while(cin>>P>>T>>G1>>G2>>G3>>GJ)
     72     {
     73         if(T>P)cout<<"Data Error!"<<endl;
     74         //((G1-G2)<=0)?(isTwoLarger = true):(isTwoLarger = false);
     75         //if(isTwoLarger)temp = G2 - G1;
     76         //else temp = G1 - G2;
     77         //if(temp<=T)final = (G1+G2)/2.0;
     78         //else if(isTwoLarger)
     79         //{
     80         //    if(G3<=G1)
     81         //        if((G1-G3)>T)final = GJ;
     82         //        else final = (G3+G1)/2.0;
     83         //    else if(G3>G2)
     84         //        if((G3-G2)>T)final = GJ;
     85         //        else final = (G3+G2)/2.0;
     86         //    else 
     87         //    {
     88         //        temp = G3-G1;
     89         //        temp3 = G2-G3;
     90         //        if((temp<=T)&&(temp3<=T))final = G2;
     91         //        else if((temp>T)&&(temp3>T))final = GJ;
     92         //        else if((temp3-temp)>0)
     93         //            final = (G3+G1)/2.0;
     94         //        else final = (G3+G2)/2.0;
     95         //    }
     96         //}
     97         //else
     98         //{
     99         //    if(G3<=G2)
    100         //        if((G2-G3)>T)final = GJ;
    101         //        else final = (G3+G2)/2.0;
    102         //    else if(G3>G1)
    103         //        if((G3-G1)>T)final = GJ;
    104         //        else final = (G3+G1)/2.0;
    105         //    else 
    106         //    {
    107         //        temp = G3-G2;
    108         //        temp3 = G1-G3;
    109         //        if((temp<=T)&&(temp3<=T))final = G1;
    110         //        else if((temp>T)&&(temp3>T))final = GJ;
    111         //        else if((temp3-temp)>0)
    112         //            final = (G3+G2)/2.0;
    113         //        else final = (G3+G1)/2.0;
    114         //    }
    115         //}
    116         if(sAbs(G1-G2)<=T)final = (G1+G2)/2.0;
    117         else if((sAbs(G1-G3)<=T)&&(sAbs(G2-G3)<=T)) final = max(G1,G2,G3);
    118         else if(sAbs(G2-G3)<=T) final = (G2+G3)/2.0;
    119         else if(sAbs(G1-G3)<=T)final = (G1+G3)/2.0;
    120         else final = GJ;
    121         cout<<fixed<<::setprecision(1)<<final<<endl;
    122         //printf("%.1f
    ",final);
    123     }
    124     return 1;
    125 }
    126 
    127 //#include <iostream>
    128 //#include <iomanip>
    129 //#include <cmath>
    130 //using namespace std;
    131 //double getMax( double x, double y, double z)
    132 //{
    133 //    return
    134 //    (x>y)?
    135 //        ((x>z)?x:z)
    136 //        :((y>z)?y:z);
    137 //
    138 //}
    139 //int main()
    140 //{
    141 //    double P,T,G1,G2,G3,GJ;
    142 //    double final;
    143 //    cin>>P>>T>>G1>>G2>>G3>>GJ;
    144 //    if(abs(G1-G2)<=T)
    145 //    {
    146 //        cout<<fixed<<::setprecision(1)<<(G1+G2)/2.0<<endl;
    147 //    }
    148 //    else if(abs(G3-G1)<=T&&abs(G3-G2)<=T)
    149 //    {
    150 //        cout<<fixed<<::setprecision(1)<<getMax(G1,G2,G3)<<endl;
    151 //    }
    152 //    else if(abs(G3-G2)<=T)
    153 //    {
    154 //        cout<<fixed<<::setprecision(1)<<(G3+G2)/2.0<<endl;
    155 //    }
    156 //    else if(abs(G3-G1)<=T)
    157 //    {
    158 //        cout<<fixed<<::setprecision(1)<<(G3+G1)/2.0<<endl;
    159 //    }
    160 //    else
    161 //    {
    162 //        cout<<fixed<<::setprecision(1)<<GJ<<endl;
    163 //    }
    164 //    return 0;
    165 //
    166 //}
  • 相关阅读:
    Java应用开发与实践
    大话存储:存储系统底层架构原理极限剖析(终极版)
    Excel 2016公式与函数应用大全
    Excel高效办公应用技巧
    业务弯路池子
    一个现象,
    为什么有时候 进入这么多次,一次是 38次,一次是 114次,
    恶心 从判断开始,
    but,
    这两个的意思是不同的。。。
  • 原文地址:https://www.cnblogs.com/suanec/p/4556855.html
Copyright © 2020-2023  润新知