hdu 1207 汉诺塔II

来源:互联网 发布:网络爬虫 python 编辑:程序博客网 时间:2024/06/08 06:21
#include<iostream>  #include<cmath>  #define M 99999999 using namespace std; int main()  {      int i,n,x,min,f[65];      f[1]=1;      f[2]=3;      for(i=3;i<=65;i++)      {          min=M;          for(x=1;x<i;x++)              if(2*f[x]+pow(2,i-x)-1<min)                  min=2*f[x]+(int)pow(2,i-x)-1;              f[i]=min;      }      while(cin>>n)          cout<<f[n]<<endl;return 0;  }