fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. typedef pair<ll,ll>ii;
  6. #define X first
  7. #define Y second
  8. #define pb push_back
  9. #define FOR(i,a,b) for(ll i=a;i<=b;i++)
  10. #define FORD(i,a,b) for(ll i=a;i>=b;i--)
  11. #define all(a) (a).begin(),(a).end()
  12. #define uni(a) (a).resize(unique(all(a)) - (a).begin())
  13. const ll mod = 1e9+7;
  14. const ll maxN = 1e6+5;
  15. const ll N = 1e6;
  16.  
  17. ll A,B,t;
  18.  
  19. void solve() {
  20. cin >> A >> B >> t;
  21.  
  22. double tmp = (double)(A+B) / 2;
  23.  
  24. if (tmp >= t) {
  25. cout << 2 << endl;
  26. return;
  27. }
  28.  
  29. double cnt = (double)(t - A) / (tmp - t);
  30. ll c1 = floor(cnt);
  31. if (c1 %2 ==1) c1--;
  32. ll c2 = c1 + 2;
  33.  
  34. double res1 = (c1/2.0 * (A+B) + A) / (c1+1.0);
  35. double res2 = (c2/2.0 * (A+B) + A) / (c2+1.0);
  36. // cout << c1 << " " << c2 << endl;
  37. // cout << res1 << " " << res2 << endl;
  38. if (abs(res1 - t) <= abs(res2-t)) cout << c1 + 1 << endl;
  39. else cout << c2 + 1 << endl;
  40.  
  41.  
  42. }
  43.  
  44. int main() {
  45. //freopen("input.txt", "r", stdin);
  46. //freopen("output.txt", "w", stdout);
  47. ios_base::sync_with_stdio(0);
  48. ll T;
  49. cin >> T;
  50. while (T--) {
  51. solve();
  52. }
  53. return 0;
  54. }
  55.  
  56.  
  57.  
  58.  
Success #stdin #stdout 0s 4408KB
stdin
3
30 10 20
41 15 30
18 13 18
stdout
2
7
1