SHARE
TWEET

codeforce - Computer Game

jakaria_hossain Jun 27th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     long long int q,n,k,a,b;
  7.     cin>>q;
  8.     while(q--)
  9.     {
  10.         long long ans,x,y,z;
  11.         cin>>k>>n>>a>>b;
  12.         if(k<=n*b)
  13.         {
  14.             ans=-1;
  15.         }
  16.         else
  17.         {
  18.             x=k-(n*b);
  19.             y=(x-1)/(a-b);
  20.             if(y>=0)
  21.             {
  22.                 ans=min(n,y);
  23.             }
  24.             else ans=-1;
  25.         }
  26.         cout<<ans<<endl;
  27.     }
  28.     return 0;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top