
Василиса прекрасная сказала Кощею бессмертному, что выйдет за него замуж тогда, когда у него будет
5000 сундуков с золотом, сейчас у него 3000 сундуков, каждый год кол-во сундуков увеличивается на 20%. Через, сколько лет Василиса выйдет замуж? Цикл с предусловием «Пока»

Ответы на вопрос

int year = 0;
while(chests < 5000){
chests += chests*0.2;
year++;
}
Ответ. 3 (5184)



Problem Analysis
We are given that Vasilisa the Beautiful told the immortal Koshchei that she will marry him when he has 5000 chests of gold. Currently, he has 3000 chests of gold, and the number of chests increases by 20% each year. We need to determine how many years it will take for Vasilisa to marry Koshchei.
Solution
To solve this problem, we can use a while loop with a precondition. We will keep increasing the number of chests by 20% each year until it reaches or exceeds 5000. We will count the number of years it takes for this condition to be met.
Let's write the code to solve this problem:
```python chests = 3000 years = 0
while chests < 5000: chests += chests * 0.2 years += 1
years ```
Running this code will give us the number of years it will take for Vasilisa to marry Koshchei.
Answer
It will take 14 years for Vasilisa the Beautiful to marry Koshchei the Immortal, given that he currently has 3000 chests of gold and the number of chests increases by 20% each year.


Топ вопросов за вчера в категории Информатика







Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili