[PTA] 7-35 monkey eating peaches problem (15 points)

A monkey off his first day of a number of peach, half eaten immediately, not fun, but also eat a; the next morning in turn eaten by the remaining peach half, then eat one. I eat every morning before the rest of the day after half a plus. When the N-morning want to eat, see only one peach. Q: The first day how many peaches were picked?

Input format:
input given positive integer N (1 <N≤10) in a row.

Output format:
output line number on the first day were picked peaches.

Sample input:
3

Sample output:
10

#include <stdio.h>
int main()
{
    int x=1,n;
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        x=(x+1)*2;
    }
    printf("%d",x);

    return 0;
}
Published 48 original articles · won praise 0 · Views 307

Guess you like

Origin blog.csdn.net/weixin_46399138/article/details/105414027