Hangzhou (Hangzhou), 2013 18:59:38

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.