Peach note
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 34943 accepted submission (s): 26317
Problem description those who like travel to the West certainly know the story of Wukong Stealing peaches. You must all think that this monkey is too busy. In fact, you may not know that Wukong is studying a mathematical problem!
What's the problem? The question he studied is how many peaches are there!
However, in the end, he still failed to solve this problem.
The current situation was as follows:
On the first day, Wukong eats more than half of peaches. On the second day, Wukong eats more than half of the remaining peaches, and then eats more than half of the remaining peaches each day, by the nth day, only one peach was left. How many peaches are there when he started eating on the first day?
There are multiple groups of input data. Each group occupies one row and contains a positive integer N (1 <n <30), indicating that only one peach is generated on the nth day.
For each group of input data, output the total number of peaches that are consumed at the beginning of the first day. Each test instance occupies one row.
Sample input24
Sample output422
1 #include<cstdio> 2 int main() 3 { 4 int n; 5 while(scanf("%d",&n)==1) 6 { 7 if(n<=1||n>=30)return 0; 8 int sum=1; 9 for(int i=1;i<n;i++)sum=(sum+1)*2;10 printf("%d\n",sum);11 }12 return 0;13 }
Hangzhou (Hangzhou), 2013 18:59:38