猴子吃桃问题。猴子第一天摘下若干桃子,当即吃了一半,还不过瘾,又多吃了一个。第二天早上又将剩下的桃子吃掉一半,又多吃了一个。以后每天早上都吃了前一天剩下的一半零一个。到第 10 天早上想再吃时,见只剩一个桃子了。编程求第一天共摘下多少桃子。
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
const int d = 9;//吃桃次数
int main() {
int n;//桃子总数
int m = 1;//现余桃数
for (int i = 1; i <= d; i++) {
m = (m + 1) * 2;
}
cout << m / 2 + 1 << endl;
}