Loading...

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

LilianaVelvheva avatar LilianaVelvheva 17 Точки

Къде ми е грешката в тази задача и защо judge ми дава 10 точки?

Това е моят код.

https://pastebin.com/Q3GcXwFj

Black Flag

 

Pirates are invading the sea and you're tasked to help them plunder

Create a program that checks if a target plunder is reached. First you will receive how many days the pirating lasts. Then you will receive how much the pirates plunder for a day. Last you will receive the expected plunder at the end.

Calculate how much plunder the pirates manage to gather. Each day they gather plunder. Keep in mind that every third day they attack more ships and they add additional plunder to their total gain which is 50% of the daily plunder. Every fifth day the pirates encounter a warship and after the battle they lose 30% of their total plunder.

If the gained plunder is more or equal to the target print the following:

"Ahoy! {totalPlunder} plunder gained."

If the gained plunder is less than the target. Calculate the percentage left and print the following:

"Collected only {percentage}% of the plunder."

Both numbers should be formatted to the 2nd decimal place.

Input

  • On the 1st line you will receive the days of the plunder – an integer number in the range [0…100000]
  • On the 2nd line you will receive the daily plunder – an integer number in the range [0…50]
  • On the 3rd line you will receive the expected plunder – a real number in the range [0.0…10000.0]

Output

  •  In the end print whether the plunder was successful or not following the format described above.

Examples

Input

Output

5
40
100

Ahoy! 154.00 plunder gained.

Comments

The days are 5 and the daily plunder is 40. On the third day the total plunder is 120 and since it is a third day, they gain an additional 50% from the daily plunder which adds up to 140. On the fifth day the plunder is 220, but they battle with a warship and lose 30% of the collected cargo and the total becomes 154. That is more than the expected.

 

10

20

380

Collected only 36.29% of the plunder.

 

Тагове:
0
Programming Fundamentals
Axiomatik avatar Axiomatik 2422 Точки

Just one small change and code gives 100%:

        if (days % 3 === 0) { // ERROR
            total += plunderForDay * 0.5;
        }
        if (days % 5 === 0) { // ERROR
            total -= total * 0.3;
        }

should be 

        if (i % 3 === 0) {
            total += plunderForDay * 0.5;
        }
        if (i % 5 === 0) {
            total -= total * 0.3;
        }

 

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