python贪吃的猴子问题,详情请看http://47.104.212.215/problem/21

贪吃的猴子python怎么做啊,请尽快回答,采纳有奖。更友好豪华大礼2413414213424

只需要确定最后一天,一定剩余1个桃,前一天吃了一半加天数加今天剩的一个,就得到了每天没吃桃的时候,都是 (d+n)*2


def f(d):
    n = 1
    x = [n]
    while d > 1:
        d -= 1
        n = (d + n) * 2
        x.append(n)
    x.sort(reverse=True)
    return x

days=f(10)

print('一共有{}个桃'.format(days[0]),days)

img

n=int(input())
peach = 1
for i in range(n-1):
    peach = (peach + 1)  * 2
print(peach)

1