Adopt reverse thinking:
/* The Monkey eats peaches. On the first day, the monkey picked up a few peaches, and immediately eats half of them, and then eats another one. In the morning of the next day, I eat half of the remaining half and one more. In the future, I will eat the remaining half of the day before yesterday and only the last peach in the morning of 10th. I picked a few peaches on the first day. */# Include <stdio. h> int main () {int sum; // total peach count int day = 9; // Number of days int temp = 1; while (day! = 0) {// 1 peach in 10th days, then the number of peaches in 9th days = (the remaining number of peaches in 10th days + 1) 2 times after temp = 2 * (temp + 1); // The number of peaches on the first day is 2 times the day after the number on the first day plus the number on the second day --;} sum = temp; printf ("% d \ n", sum); // The answer is 1534 peaches return 0 ;}
Peach eating for monkeys