题目大意:有两部电梯,一个在a层,一个在b层向c层走,问哪部电梯更快到达1层
思路:第一部电梯的到达时间就是他所在的层数,第二部电梯需要讨论他当前是在上行还是下行,下行则时间为b,上行时间为2c-b
1<=a,b,c<=1e8,b!=c
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int temp = c - b + c;//假设第二个电梯在上行,它到达1层所需时间
if (b > c)
{//判断是否下行
temp = b;//第二个电梯在下行,他到达1层所需时间
}
if (a < temp)
{//第一个电梯到达1层时间为a
printf("1\n");
}
else if (a > temp)
{
printf("2\n");
}
else
{
printf("3\n");
}
}
return 0;
}