题解 | #Grading#

Grading

https://www.nowcoder.com/practice/23e3244406724ffa8330760f640c8149

//送分题,就是麻烦一点
#include "stdio.h"
#include "math.h"
#include "algorithm"
using namespace std;

int main(){
    double F,T,G1,G2,G3,GJ;//full-mark,tolerance
    while (scanf("%lf%lf%lf%lf%lf%lf",&F,&T,&G1,&G2,&G3,&GJ) != EOF){
        double difference1 = fabs(G1-G2);
        if(difference1 <= T){
            printf("%.1lf\n",(G1+G2)/2);
            continue;
        } else {
            double difference2 = G3-G1;
            double difference3 = G3-G2;
            if(difference2 <= T && difference3 <= T){
                double max = G1>G2?G1:G2;
                max = max>G3?max:G3;
                printf("%.1lf\n",max);
                continue;
            } else if (difference2 <= T || difference3 <= T){
                if (fabs(G3-G1) < fabs(G3-G2)){
                    printf("%.1ld\n",(G3+G1)/2);
                    continue;
                } else{
                    printf("%.1ld\n",(G3+G2)/2);
                    continue;
                }
            } else{
                printf("%.1lf\n",GJ);
            }
        }
    }
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-26 18:54
说等下个版本吧的发呆爱好者很贪睡:佬最后去了哪家呀
点赞 评论 收藏
分享
我即大橘:耐泡王
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务