Strange Towers of Hanoi
h[i]
表示 i 個圓盤借助一個圓盤,轉移到另一個圓盤上需要的次數。
// Created by CAD on 2020/3/1.
#include <bits/stdc++.h>
#define mst(name, value) memset(name,value,sizeof(name))
using namespace std;
int h[15],f[15];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
for(int i=1;i<=12;++i) h[i]=2*h[i-1]+1;
mst(f,0x3f);
f[1]=1;
for(int i=2;i<=12;++i)
for(int j=1;j<i;++j)
f[i]=min(f[i],2*f[j]+h[i-j]);
for(int i=1;i<=12;++i)
cout<<f[i]<<"\n";
return 0;
}