fork download
  1. #include<bits/stdc++.h>
  2. #include<ext/pb_ds/assoc_container.hpp>
  3. #include<ext/pb_ds/tree_policy.hpp>
  4. using namespace __gnu_pbds;
  5. using namespace std;
  6.  
  7. template<typename T>
  8. using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
  9.  
  10. #define ll long long
  11. #define ull unsigned long long
  12. #define pi pair<ll,ll>
  13. #define pii pair<ll,pi>
  14. #define inf 1000000000000000000
  15. #define iinf -1000000000000000000
  16. #define __ ios_base::sync_with_stdio(0);cin.tie();cout.tie();
  17. #define mod 1000000007
  18. #define base 1949313259
  19. #define en '\n'
  20.  
  21. ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
  22. ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
  23. bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
  24.  
  25. ll ar[]={0,0,1,-1};
  26. ll br[]={1,-1,0,0};
  27.  
  28. ll bigmod(ll n,ll pow){
  29. if(pow==0) return 1;
  30. if(pow==1) return n%mod;
  31.  
  32. ll ans=bigmod(n,pow/2);
  33. ans=(ans*ans)%mod;
  34.  
  35. if(pow%2==1){ans=(ans*n)%mod;}
  36. return ans%mod;
  37. }
  38.  
  39. ll fact[1000005];
  40.  
  41. ll nCr(ll n,ll r){
  42.  
  43. ll ans=fact[n];
  44. ans=(ans*bigmod(fact[r],mod-2))%mod;
  45. ans=(ans*bigmod(fact[n-r],mod-2))%mod;
  46. return ans;
  47. }
  48.  
  49. string s[200],s1,s2;
  50. ll n,m;
  51. ll arr[500010];
  52. ll brr[500010];
  53. vector<ll>v,v1;
  54.  
  55. map<ll,ll>mp;
  56. ll vis[500005];
  57.  
  58. int main()
  59. {__
  60. ll i,j,z,a;
  61. double b,c,d,e,f,h,g,x,y,t,k,l,r;
  62. fact[0]=1;
  63.  
  64. // for(i=1;i<=1000000;i++) fact[i]=(fact[i-1]*i)%mod;
  65. ll ans=0,sum=0,temp;
  66. cin>>n;
  67. for(ll cz=0;cz<n;cz++){
  68. cin>>h>>c>>t;
  69. if(abs(((h+c)/2.0)-t)<=0.00000001||(h+c)/2>t){cout<<2<<endl;continue;}
  70. // cout<<(h+c)/2-c<<endl;
  71. m=abs((ll)(h-t+c-t));
  72. z=abs((ll)(t-h));
  73. a=z/m;
  74. a=max(0LL,a-1000);
  75. double diff=1000000000000000;
  76.  
  77. for(i=0;i<=1005;i++,a++){
  78. r=(a+1)*h+a*c;
  79. r/=(double)(2.0*a+1.0);
  80. if(abs(r-t)<diff){ans=a;diff=abs(r-t);}
  81. }
  82. cout<<ans*2+1<<endl;
  83. }
  84. }
Success #stdin #stdout 0s 4376KB
stdin
1
999977 17 499998
stdout
499979