文章
4
粉丝
171
获赞
5
访问
16.8k
根据题目给出的规则,进行模拟
#include<iostream>
#include<cmath>
using namespace std;
int main(){
double p, t, g1, g2, g3, gj;
while(scanf("%lf%lf%lf%lf%lf%lf", &p, &t, &g1, &g2, &g3, &gj)!=EOF){
if(fabs(g1-g2)<=t){
printf("%.1lf", (g1+g2)/2);
}else if(fabs(g3-g1)<=t && fabs(g3-g2)<=t){
printf("%.1lf", (g1+g2+g3)/2);
}else if(fabs(g3-g1)>t && fabs(g3-g2)>t){
printf("%.1lf", gj);
}else {
if(fabs(g3-g1) < fabs(g3-g2))
printf("%.1lf", (g1+g3)/2);
else printf("%.1lf", (g2+g3)/2);
}
}
}
登录后发布评论
暂无评论,来抢沙发