Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

alex80 avatar alex80 2 Точки

Nether Realms

Здравейте , колеги.Тая задача ме отрепа по условието всико излиза Judge 80/100

какво греша два теста с груба грешка   

 Screenshot-2

https://pastebin.com/mPZMuTNB

 

Problem 3 – Nether Realms

Mighty battle is coming. In the stormy nether realms, demons are fighting against each other for supremacy in a duel from which only one will survive.

Your job, however is not so exciting. You are assigned to sign in all the participants in the nether realm's mighty battle's demon book, which of course is sorted alphabetically.

A demon's name contains his health and his damage.

The sum of the asci codes of all characters (excluding numbers (0-9), arithmetic symbols ('+', '-', '*', '/') and delimiter dot ('.')) gives a demon's total health.

The sum of all numbers in his name forms his base damage. Note that you should consider the plus '+' and minus '-' signs (e.g. +10 is 10 and -10 is -10). However, there are some symbols ('*' and '/') that can further alter the base damage by multiplying or dividing it by 2 (e.g. in the name "m15*/c-5.0", the base damage is 15 + (-5.0) = 10 and then you need to multiply it by 2 (e.g. 10 * 2 = 20) and then divide it by 2 (e.g. 20 / 2 = 10)).

So, multiplication and division are applied only after all numbers are included in the calculation and in the order they appear in the name.

You will get all demons on a single line, separated by commas and zero or more blank spaces. Sort them in alphabetical order and print their names along their health and damage.

Input

The input will be read from the console. The input consists of a single line containing all demon names separated by commas and zero or more spaces in the format: "{demon name}, {demon name}, … {demon name}"

Output

Print all demons sorted by their name in ascending order, each on a separate line in the format:

"{demon name} - {health points} health, {damage points} damage"

Constraints

  • A demon's name will contain at least one character
  • A demon's name cannot contain blank spaces ' ' or commas ','
  • A floating point number will always have digits before and after its decimal separator
  • Number in a demon's name is considered everything that is a valid integer or floating point number (with dot '.' used as separator). For example, all these are valid numbers: '4', '+4', '-4', '3.5', '+3.5', '-3.5'

Examples

Input

Output

Comments

M3ph-0.5s-0.5t0.0**

M3ph-0.5s-0.5t0.0** - 524 health, 8.00 damage

M3ph-0.5s-0.5t0.0**:

Health = 'M' + 'p' + 'h' + 's' + 't' = 524 health.

Damage = (3 + (-0.5) + (-0.5) + 0.0) * 2 * 2 = 8 damage.

Input

Output

Comments

M3ph1st0**, Azazel

Azazel - 615 health, 0.00 damage

M3ph1st0** - 524 health, 16.00 damage

 

Azazel:

Health - 'A' + 'z' + 'a' + 'z' + 'e' + 'l' = 615 health. Damage - no digits = 0 damage.

 

M3ph1st0**:

Health - 'M' + 'p' + 'h' + 's' + 't' = 524 health.

Damage - (3 + 1 + 0) * 2 * 2 = 16 damage.

Gos/ho

Gos/ho - 512 health, 0.00 damage

 

       

 

 

 

 

Тагове:
0
PHP Fundamentals 21/02/2020 14:05:09
willystyle avatar willystyle 2472 Точки

с един ksort($demons) стигаш до 80.

За останалите 20 трябва да печаташ с number_fomat, понеже .f na printf явно не харесва някои входове.

https://pastebin.com/WQhhPEgL

0
alex80 avatar alex80 2 Точки

благодаря

1
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.