Dmaxiya

[蓝桥杯 2026 省 A] 拦截程序 参考代码

Apr 11th, 2026
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define endl '\n'
  5.  
  6. typedef long long LL;
  7. const int maxn = 1000000 + 100;
  8. int C;
  9. LL L, V, T;
  10.  
  11. int main() {
  12.     ios::sync_with_stdio(false);
  13.  
  14.     cin >> C;
  15.     while (C--) {
  16.         cin >> L >> V >> T;
  17.         LL Pa = V * T;
  18.         LL Pb = L - V * T;
  19.         LL mid = (Pa + Pb) / 2;
  20.         cout << max(abs(mid - Pa), abs(mid - Pb)) << endl;
  21.     }
  22.  
  23.     return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment