首页 >
> 详细

Consider a population of "prime insects" and "even eating predators". In all possible scenarios we are considering, there are i insects to begin with (where i >= 50 and i is an even number) and p predators (where p >= 5) to begin with (week 0). Given these initial numbers, the insect population at the end of week n is calculated as follows in the following order:

1.For each week w up until and including week n, if w is a prime number that is greater than or equal to 3 (i.e. 3, 5, 7, 11 …), then half of the insects in the population give birth to two more insects, resulting in x insects

2.After any reproduction from #1 (the rule stated above), the resulting number x can be reduced in two ways:

oFor each week n where n is an even number, each of the predators eats 2 insects. This eating is such that predators will select their prey strictly in order from youngest to oldest; if a predator p eats an insect i, then there are no insects younger than i remaining.

oAll insects born 10 weeks prior to week n that are still alive naturally die off.

Suppose that i = 50 and p = 5. Then the sequence for the first 13 weeks would look like the following list (there are 14 items because we are including week 0 in the first position):

[50, 50, 40, 80, 70, 140, 130, 260, 250, 250, 200, 400, 390, 750]

Notice that at week 10, when insects first start naturally dying, the number goes down to 200, because predators ate 10 of the youngest insects (week 10 is an even numbered week) and the 40 remaining insects from week 0 (10 of the initial 50 were eaten in week 2) naturally died off. No new insects are born between Weeks 0 and 2. Week 13 sees 750 insects, because numbers doubled from 390 the previous week (to get 780), but that number is reduced by 30 to 750 because of the 40 born in week 3, 10 were eaten in week 4 and so only 30 naturally die out.

Given inputs i (number of initial insects), p (number of initial predators) and n (number of weeks), your program should calculate the number of insects (z) calculated to be alive after n weeks and output the following string:

There are z insects at week n

You may assume that the 3 inputs into this program will be valid: all integers, i >= 50 and i is an even number, and p >= 5.

Note that given this setup, for some inputs the number sequence will get to a point where at some week w the population falls to 0, which means that by that week the population of insects (and subsequently predators) became extinct. For example, suppose that i = 52 and p = 12. Then the sequence to week 12 is the following, and at week 12 the population became extinct:

[52, 52, 28, 56, 32, 64, 40, 80, 56, 56, 4, 8, 0]

Here, the population at week 11 is 8, but due to predators eating that remaining amount in week 12, the numbers go down to zero. In such cases, your output should instead be:

The insects became extinct at week 12

Example 1:

What is the number of weeks? 17

How many insects to begin with? 50

How many predators to begin with? 5

There are 1230 insects at week 17

Example 2:

What is the number of weeks? 5

How many insects to begin with? 100

How many predators to begin with? 10

There are 280 insects at week 5

Example 3:

What is the number of weeks? 21

How many insects to begin with? 82

How many predators to begin with? 10

There are 2950 insects at week 21

Example 4:

What is the number of weeks? 18

How many insects to begin with? 50

How many predators to begin with? 11

The insects became extinct at week 15

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-23:00
- 微信：codinghelp2

- 代写data留学生作业、代做analysis课程作业、代写python，C+ 2020-09-30
- 代写data Analysis作业、代做python，Java程序语言作业、 2020-09-30
- Program课程作业代写、代做python，Java，C++程序语言作业、 2020-09-30
- 代做sit202课程作业、Networks作业代做、Java，C++程序设计 2020-09-30
- 代写data留学生作业、代做c++课程设计作业、C++程序语言作业调试代写留 2020-09-30
- 159100留学生作业代做、代写programming作业、C++编程语言作 2020-09-29
- Engineering作业代做、代写html/Css语言作业、代写web程序 2020-09-29
- 代写kit206/506作业、代做system课程作业、代写sql程序设计作 2020-09-29
- Lab 2 Jsf作业代做、Java编程语言作业调试、Java实验作业代写、 2020-09-29
- 代写mis275留学生作业、代做analytics作业、代做python，J 2020-09-28
- Html留学生作业代做、代写css/Java编程语言作业、代做java实验作 2020-09-28
- Comp3278作业代写、Database作业代做、代写sql实验作业、Sq 2020-09-28
- Macm 204课程作业代做、C/C++，Java，Python程序设计作业 2020-09-28
- Cis 484作业代做、代写sql编程语言作业、代做sql课程设计作业、代写 2020-09-27
- 代写kit206课程作业、代做software留学生作业、代写c++程序语言 2020-09-27
- Comp2100作业代做、代写programming作业、C/C++编程设计 2020-09-27
- Msbd5015作业代写、Python编程语言作业调试、代写python课程 2020-09-27
- Programming作业代写、Java程序设计作业调试、代做algorit 2020-09-27
- Cisc 360作业代做、代写java程序设计作业、Python，C++语言 2020-09-27
- Cs 570留学生作业代做、Java程序语言作业调试、代写java课程设计作 2020-09-27