#C773. Calculate Deck Power
Calculate Deck Power
Calculate Deck Power
You are given a deck of cards where each card is represented as a string in the following format:
<name>, <base_power>, <rarity>
The base_power is a positive integer and rarity can be one of the following: Common
, Rare
, Epic
, or Legendary
.
The total power for each card is computed as:
\(\text{total} = \text{base_power} \times multiplier\)
with the multipliers defined as follows:
- Common: \(1\)
- Rare: \(1.5\)
- Epic: \(2\)
- Legendary: \(3\)
The overall deck power is the sum of the power for each card. Note that the final answer should be returned as an integer (by truncating any fractional part).
Input Format: The input is read from standard input. The first line contains an integer \(n\) representing the number of cards. This is followed by \(n\) lines, each containing a card description string in the format specified above.
Output Format: Output a single integer which is the total power of the deck.
inputFormat
The first line contains an integer n (1 (\leq) n (\leq) 1000), the number of cards. Each of the following n lines contains a card description in the format ", <base_power>, ". Note that <base_power> is an integer and is one of the strings: Common, Rare, Epic, or Legendary.
outputFormat
Output a single integer which is the total power of the deck. The total power is computed by summing the product of base power and the corresponding rarity multiplier for each card. Any fractional part is truncated.## sample
4
Dragon, 300, Legendary
Wizard, 150, Epic
Knight, 200, Rare
Archer, 100, Common
1600