题解 第二章暴力求解| #Grading#
Grading
http://www.nowcoder.com/practice/23e3244406724ffa8330760f640c8149
#include <bits/stdc++.h>
using namespace std;
int main()
{
int P, T, G1, G2, G3, GJ;
double FinalG;
while (cin >> P >> T >> G1 >> G2 >> G3 >> GJ)
{
if (abs(G1 - G2) <= T)
FinalG = double(G1 + G2) / 2;
else
{
if (abs(G3 - G1) <= T && abs(G3 - G2) <= T)
FinalG = max({G1, G2, G3});
else if (abs(G3 - G1) > T && abs(G3 - G2) > T)
FinalG = GJ;
else
{
if (abs(G3 - G1) <= abs(G3 - G2))
FinalG = double(G3 + G1) / 2;
else
FinalG = double(G3 + G2) / 2;
}
}
cout << fixed << setprecision(1) << FinalG << endl;
}
return 0;
}
王道机试指南刷题 文章被收录于专栏
计划刷完这本书