[POJ1958]Strange Towers of Hanoi (递推)

Posted fsy2017

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[POJ1958]Strange Towers of Hanoi (递推)相关的知识,希望对你有一定的参考价值。

技术分享图片

POJ炸了

所以放这里来

#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<algorithm>
#include<iostream>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define N 12
int d[13], f[13];
using namespace std;
int main()
{
    d[1] = 1;
    for (int i = 2; i <= N; ++i) d[i] = 2 * d[i-1] + 1;
    memset(f, 0x3f, sizeof(f));
    f[1] = 1,f[2]=3;
    for (int i = 1; i <= N; ++i)
    {
            for(int j=1;j<i;++j)
                f[i] = min(2 * f[j] + d[i - j], f[i]);
        printf("%d
", f[i]);
    }
    return 0;
}

 

以上是关于[POJ1958]Strange Towers of Hanoi (递推)的主要内容,如果未能解决你的问题,请参考以下文章

[POJ1958]Strange Towers of Hanoi (递推)

Strange Towers of Hanoi (POJ1958)

[POJ1958]Strange Towers of Hanoi

POJ 1958 Strange Towers of Hanoi 解题报告

Prob.2[动态规划+递推+划归思想的应用]POJ 1958 Strange Towers Of Hanoi Upd:2020.3.1

poj——2891 Strange Way to Express Integers