PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SCKTIFELSE0000005. Tính tiền điện theo bậc (Tiered Electricity Bill)

    ID: 1494 Loại: Thông thường 2000ms 256MiB Tried: 8 Đã chấp nhận: 1 Độ khó: 4 Đăng bởi: Nhãn>FundamentalsInteger arithmeticImplementation techniquesBasic mathematics

Bài tập này chưa được xếp vào lộ trình.

Tính tiền điện theo bậc (Tiered Electricity Bill)

Tiered Electricity Bill

Version: Phuoc Hung OJ Extended

Problem Statement

A lodging house charges monthly electricity usage using three progressive tiers. The first 5050 kWh cost 18001800 VND per kWh. The next 5050 kWh (from the 51st through the 100th) cost 22002200 VND per kWh. Every kWh from the 101st onward costs 28002800 VND. Each unit is charged at the rate of its own tier, rather than charging all units at the highest rate. Every customer also pays a fixed service fee of 1500015000 VND. Type H customers receive no discount. Type S customers receive a 10%10\% discount on the tiered electricity charge, but not on the service fee. Given the monthly kWh usage and customer category, calculate the final amount due.

Input

One line contains the integer nn, the number of kWh used, and the character kk (H or S), the customer category, separated by one space.

Output

Print a single integer: the total amount due in Vietnamese dong, with no currency symbol or thousands separators.

Subtasks

  • Subtask 1 (20 points): 0≤n≤500\le n\le50; k=Hk=\texttt{H}

  • Subtask 2 (30 points): 0≤n≤1000\le n\le100; k∈{H,S}k\in\{\texttt{H},\texttt{S}\}

  • Subtask 3 (50 points): 0≤n≤10000\le n\le1000; k∈{H,S}k\in\{\texttt{H},\texttt{S}\}

Examples

Example 1

Input

0 S

Output

15000

Explanation

Usage of 00 kWh incurs no electricity charge; the discount remains zero, and the 1500015000 VND service fee is added.

Example 2

Input

75 H

Output

160000

Explanation

Tier 1 costs 50×1800=9000050\times1800=90000 VND and tier 2 costs 25×2200=5500025\times2200=55000 VND. The electricity charge is 145000145000 VND. Type H gets no discount, so the total is 145000+15000=160000145000+15000=160000 VND.

Example 3

Input

120 S

Output

245400

Explanation

Tier 1 costs 9000090000 VND, tier 2 costs 110000110000 VND, and tier 3 costs 20×2800=5600020\times2800=56000 VND. Electricity is 256000256000 VND, discounted by 10%10\% to 230400230400 VND. Adding 1500015000 VND gives 245400245400 VND.