题解:P12647 [KOI 2024 Round 2] 寻宝游戏
kuaiCreator · · 题解
解题思路
考虑
代码实现
#include<bits/stdc++.h>
using namespace std;
int main() {
int T, l, r, s;
cin >> T;
while (T--) {
cin >> l >> r >> s;
int dl = abs(s - l), dr = abs(r - s);
if (dr <= dl) {
cout << (dr * 2) << endl;
} else {
cout << (dl * 2) +1 << endl;
}
}
return 0;
}