#include "stdafx.h"
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int a[65];
memset(a,0x3f,sizeof(a));
a[0]=0;
for(int i=1;i<65;i++)
{
for(int j=0;j<i;j++)
if(2*a[j]+pow(2,i-j)-1<a[i])
a[i]=2*a[j]+pow(2,i-j)-1;
}
int n;
while(cin>>n)
cout<<a[n]<<endl;
}
汉诺塔2
猜你喜欢
转载自blog.csdn.net/weixin_43792166/article/details/85223734
今日推荐
周排行