#include using namespace std; long T,X,A,Y,B; int main() { cin>>T>>X>>A>>Y>>B; long ans=9e18; for(int i=0;iT) { long diff=d-T; diff=(diff+B-1)/B; now+=Y*diff; d-=B*diff; } ans=min(ans,now+(T-d)); } cout<