Gym101492K Cutting Strings

Alice, Beto, and Carlos are playing with twine. Alice starts by pulling taut the string of twine, then she folds it and holds the string at the fold. Beto holds the loose ends on the other side. They then repeat the following procedure. Carlos cuts the string with scissors, thus separating Alice and Beto. Alice, without letting go of the strings she was holding, grabs the loose ends of the strings held by Beto and he does the same to the loose ends of the strings held by Alice.

How many separate strings will they have after the procedure is repeated K times?

 

Input

The input has a single integer, K.

  • 0 ≤ K ≤ 30 

 

Output

The output has a single integer, the amount of separate strings at the end of the process.

 

Examples

Input
0
Output
1
——
Input
1
Output
3
——————————————————————————————————————————————————————————————————————————————————————————————————————————
这道题太傻逼了,不得不来吐槽一下。第一次读题是对的,就是一个U型+两条线,结果推公式推错了……
直线翻倍,然后U型线变成3条线,就是(n-1)*2+3,化简就是2*n+1了。
然后输出,就结束了。真的是脑子不太清醒。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <deque>
#include <cfloat>
#include <algorithm>
typedef long long ll;
using namespace std;

int gcd(int x,int y)
{
    return y?gcd(y,x%y):x;
}

int a[50];


int main()
{
    int k;
    scanf("%d",&k);
    int ans=1;
    while(k--)
    {
        ans=2*ans+1;
    }
    printf("%d",ans);
}
View Code

 

posted @ 2020-07-10 21:36  璃灵  阅读(190)  评论(0)    收藏  举报