【杭电100题】2077 汉诺塔IV

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2077
在汉诺塔三的基础上改了点

#include <iostream>

using namespace std;

int main()
{
    __int64 x[21],y[21];
    x[1]=2;
    y[1]=2;
    for(int i=2; i<21; i++)
    {
        x[i]=3*x[i-1]+2;
        y[i]=x[i-1]+2;
    }

    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        cout<<y[n]<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41727666/article/details/88359200
今日推荐