#C5283. Maximum Delivery Earnings

    ID: 48915 Type: Default 1000ms 256MiB

Maximum Delivery Earnings

Maximum Delivery Earnings

John operates a delivery service with a fleet of trucks. He has N trucks, each capable of carrying up to W kilograms. On a given day, there are M parcels to be delivered, and each parcel weighs P kilograms. For every parcel that is delivered, John earns Q rupees.

If the total weight of all parcels, given by \(M \times P\), is less than or equal to the total carrying capacity of all trucks, \(N \times W\), then all parcels can be delivered and the total earnings will be \(M \times Q\) rupees. Otherwise, only \(\lfloor \frac{N \times W}{P} \rfloor\) parcels can be delivered, yielding earnings of \(\lfloor \frac{N \times W}{P} \rfloor \times Q\) rupees.

Your task is to compute the maximum earnings for each test scenario.

inputFormat

The input is read from standard input (stdin). The first line contains a single integer (T), representing the number of test cases. Each of the following (T) lines contains five space-separated integers: (N), (W), (M), (P), and (Q), where:

  • (N) is the number of trucks.
  • (W) is the maximum capacity (in kilograms) per truck.
  • (M) is the number of parcels.
  • (P) is the weight (in kilograms) per parcel.
  • (Q) is the earnings (in rupees) per delivered parcel.

outputFormat

For each test case, output the maximum earnings that John can obtain on a new line. The result should be printed to standard output (stdout).## sample

1
3 50 20 5 30
600

</p>