Type: Default 1000ms 256MiB

C++-循环while-猴子吃桃子

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

Description

猴子吃桃问题就是:一个猴子,看到许多的桃子,第一天吃了一半,又吃了一个,第二天也吃了一半,又吃了一个,一直这样下去,到了第10天,只剩下一个桃子了,求猴子吃桃子的过程。

首先我们要知道怎么算

假设第一天猴子吃了n个,这么说就是n-(((n/2+1)/2+1)/2+1.../2+1)=1(重复9次因为猴子第一天已经吃了桃子)这样子倒推过来就是((1+1)*2+1)*2...+1)*2=n,第一天猴子吃了1个,我们赋值于x,x一直x=(x+1)*2重复9次就可以得出从第10天到第1天猴子吃桃的过程了。

Format

Input

Output

Samples


1534

Limitation

1s, 1024KiB for each test case.

C++基础知识02(循环-for和while及嵌套)

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
18
Start at
2024-5-5 0:00
End at
2024-5-25 20:00
Duration
500 hour(s)
Host
Partic.
28