fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. long long n, x, y, z;
  7. cin>>n>>x>>y>>z;
  8.  
  9. long long tg=z;
  10. while(y!=z)
  11. {
  12. if(y>z)
  13. y=y-z;
  14. else
  15. z=z-y;
  16. }
  17.  
  18. if (tg/y<n) cout<<(tg/y);
  19. else cout<<n;
  20. return 0;
  21. }
Success #stdin #stdout 0s 15232KB
stdin
5 1 3 5
stdout
5