#B2607. Monkey and the Peaches

    ID: 11246 Type: Default 1000ms 256MiB

Monkey and the Peaches

Monkey and the Peaches

A little monkey bought a certain number of peaches. On the first day, he ate exactly half of the peaches plus one extra peach. On the second day, he did the same with the remaining peaches: he ate half of them plus one extra. On the third day, he repeated the process: he ate half of the remaining peaches plus one extra. On the fourth day, he woke up to find that only one peach was left. Determine the initial number of peaches the monkey bought.

The process can be modeled with the following equations. Let \(x\) be the initial number of peaches. Then after the first day, the remaining peaches are: \[ \frac{x}{2} - 1 \] After the second day, the remaining peaches are: \[ \frac{1}{2}\left(\frac{x}{2} - 1\right) - 1 = \frac{x}{4} - 1.5 \] After the third day, the peaches left are: \[ \frac{1}{2}\left(\frac{x}{4} - 1.5\right) - 1 = \frac{x}{8} - 1.75 \] It is given that after the third day, the remaining peaches equal 1, i.e., \[ \frac{x}{8} - 1.75 = 1 \] Solve for \(x\) to find the initial number of peaches.

inputFormat

This problem does not require any input.

outputFormat

Output a single integer representing the initial number of peaches the monkey bought.

sample

22