Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  3. #define Alhamdulillah return 0;
  4. #define pb push_back
  5. #define ins(x) insert(x)
  6. #define fi first
  7. #define se second
  8. #define lb lower_bound
  9. #define ub upper_bound
  10. #define all(v) (v.begin(),v.end())
  11. #define sz(v) ((ll)((v).size()))
  12. #define reset(v,val) memset(v,val,sizeof(v))
  13. #define erep(i, x, n) for ( i = x; i<=(ll)(n); i++)
  14. #define rep(i, x, n) for( i = x; i<(ll)(n); i++)
  15. using namespace std;
  16. typedef long long int ll;
  17. const long long int mod=1e9+7;
  18. ll dx[]={0,0,1,-1};
  19. ll dy[]={1,-1,0,-1};
  20. ll m,k,n,a[200005],ans[10],sm=0,res=0;
  21. multiset< ll >st1,st2;
  22. string s1="one",s2="zero",s,ch="";
  23. vector<ll>v[200005];
  24. vector< pair<ll,ll> >vv;
  25. vector< pair< ll,pair <ll,ll> > > vvv;
  26. priority_queue <ll> pq;
  27. map< ll , ll >cost;
  28. ll xa,xb,xc,ya,yb,yc,xres;
  29.  
  30.  
  31.  
  32. int main(){
  33. In_the_name_of_allah_the_merciful
  34.  
  35. ll i=0,x,y,j=0,z=0,q,nb0=0,nb=0,nbmax=0,nbinf=0,nb2=0,mm=5e8,idx=0,ok=0,l,mx=0,r,negatif=0,positif=0,l1,r1;
  36. multiset< ll > ::iterator it,it1,it2;
  37. char c;
  38. //freopen("a.txt.txt","r",stdin);
  39. cin>>n>>x>>y>>z;
  40. ll ans=n/x;
  41. m=n%x;
  42. ll beta=0;
  43. for(ll xx=100000000000;xx>=1;xx/=2){
  44. while((beta+xx)<=(1e18) && (m+(beta+xx)*(z-y))>=y)beta+=xx;
  45. }
  46. if(m>=y)ans++;
  47. ans+=beta;
  48. ll alpha=0;
  49. for(ll xx=100000000000;xx>=1;xx/=2){
  50. while((alpha+xx)<=(1e18) && (n+(alpha+xx)*(z-y))>=y)alpha+=xx;
  51. }
  52. if(n>=y)res++;
  53. res+=alpha;
  54. n=n+alpha*(z-y)-y;
  55. if(n<0)n=0;
  56. // cout<<alpha<<endl;;
  57. res+=(n/x);
  58. // cout<<res<<endl;
  59. cout<<max(res,ans);
  60. Alhamdulillah
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement