#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; bool rcmp(int a, int b) { return a>b; } typedef long long LL; int gw, gh, la, lb; LL ka, kb, wh; char check(LL r, LL c) { if (kb>0&&c>=gw) return 1; LL rc=r; rc*=la; LL cc=c; cc*=lb; if (rc>gh) rc=gh; if (cc>gw) cc=gw; rc*=cc; LL xx=wh-rc; rc=r; rc*=ka; cc=c; cc*=kb; if (xx<=rc+cc) return 1; return 0; } int main() { int n, r; int h, w; LL v, t, x, d, i, j, nj, xd; scanf("%d %d %d %d %lld %lld", &h, &w, &la, &lb, &ka, &kb); gh=h; gw=w; wh=h; wh*=w; r = h+w; for (i=0; ; i++) { if (i>r) break; x=i; x*=la; if (x>=h) x=0; else x=(h-x)*w; v=ka; v*=i;// t=kb; t*=w; t*=h; if (vxd) break; if (check(i, nj)) break; j=nj; } d>>=1; } j++; if (r>i+j) r=i+j; } printf("%d\n", r); return 0; }