Christmas Gifts

Company: Hsbc

Difficulty: medium

Problem Statement

Christmas Gifts Christmas is coming and Adam has lots of sisters, so he wants to give each of them a gift box. Adam has just enough money to buy exactly N chocolates and M pastries. Every gift box he prepares must satisfy one of the following two conditions: the box holds X chocolates and Y pastries, or the box holds X pastries and Y chocolates. Every chocolate and every pastry belongs to at most one box, so no sweet may be reused, and Adam is allowed to leave some chocolates or pastries unused. Both kinds of boxes may be prepared, in any mix, and Adam may prepare as many boxes of each kind as his sweets allow. Adam is busy with his assignments and wants your help: find the maximum number of gift boxes that can be made out of N chocolates and M pastries while fulfilling the conditions above. Input Format The input consists of a single line. The line contains four space-separated integers N , M , X and Y — the number of chocolates to buy, the number of pastries to buy, and the two box s