#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> h >> w >> la >> lb >> ka >> kb; ll ans = INFLL; rep(houren,2){ for(int i=0;i<=h/la+1;i++){ ll remh = max((h - i*la)*w - ka*i, 0LL); ll remw = max(h*w - ka*i, 0LL); ll upd = (remw+lb*h+kb-1)/(lb*h+kb); if(kb){ upd += (remh+kb-1)/kb; }else{ if(remh) upd = INFLL; } chmin(ans, i+upd); } swap(h,w); swap(la,lb); swap(ka,kb); } cout << ans << '\n'; return 0; }