Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

2460.   Ticket Discount
Time Limit: 0.5 Seconds   Memory Limit: 65536K
Total Runs: 207   Accepted Runs: 43



David, a manager of a world top amazing park - TheBEST, plans to invest $100K to develop an automatic system to calculate the price of the park ticket under various conditions.

The standard price of TheBEST is 100$ per entry normally. Moreover, to attract more and more tourists, TheBEST published many discounts for the entry ticket. So far, the discount policies include:

  1. 40% discount for booking the ticket 30 days in advance (including 30 days). For example, if the ticket of Nov.1 2003 is booked before Oct.3 2003, the price is 60$
  2. 30% discount for booking the ticket 15 days in advance (including 15 days). For example, if the ticket of Nov.1 2003 is booked before Oct.18 2003, the price is 70$
  3. 10% discount for booking the ticket 7 days in advance (including 7 days). For example, if the ticket of Nov.1 2003 is booked before Oct.26 2003, the price is 90$
  4. 10% discount for booking by phone directly.
  5. 20% discount for booking by travel agency.
  6. 15% discount for booking by online booking system.
  7. 10% discount for booking 5-19 tickets per time.
  8. 20% discount for booking 20 tickets or above per time.

For one booking transaction, three discount types - advance booking (1, 2, 3), none window booking (4, 5, 6) and group booking (7, 8) can be applied for together. To illustrate the above discount policies, we have the following examples booking by today (Oct.26, 2003).

Booking 1: 1 ticket for Nov.2, 2003 by phone

(1 - 10%)*(1 - 10%)*100 = 81$

Booking 2: 5 tickets for Dec.1, 2003 by travel agency <China-Tour>

(1 - 40%)*(1 - 20%)*(1 - 10%)*100 = 43.2$

Booking 3: 30 tickets for Oct.27, 2003 by online system

(1 - 15%)*(1 - 20%)*100 = 68$

You task is to write a program to help TheBEST calculate the exact price per ticket for each booking transaction.

Input

There are several booking transactions in the input, each transaction per line.

A transaction is shown as following format (4 items):

BookingDate EntryDate BookingWay Quantity

And then, the format for each item is:

BookingDate: MMM.DD YYYY
EntryDate: MMM.DD YYYY

where MMM represents the month (`Jan', `Feb', `Mar', `Apr', `May', `Jun', `Jul', `Aug', `Sep', `Oct', `Nov' and `Dec'), DD represents the 2 digits format of the day and YYYY represents the 4 digits format of the year.

Quantity: 3 digits from 001 to 999

BookingWay: `phone' or `online' or `agency <S>', where S is a string shows the agency information (length of S is within 100).

When Quantity equals to `000', the input ends.

Output

For each booking transaction, output the final price per ticket, one per line.

Sample Input

Oct.26 2003 Nov.02 2003 phone 001
Oct.26 2003 Dec.01 2003 agency <World Trade Reservation 207548> 005
Oct.26 2003 Oct.27 2003 online 030
Oct.23 2003 Oct.23 2003 online 000

Sample Output

81
43.2
68


Source: Asia - Beijing 2003
Submit   List    Runs   Forum   Statistics

Tianjin University Online Judge v1.2.4