http://ac.jobdu.com/problem.php?pid=1389
Such a problem as long as the classification do not repeat it.
Can be divided into,
Jump 0 Steps for the first time, that is, jump straight to the end.
First Jump 1 steps, then in Jump F (i-1)
First jump 2 steps, then in Jump F (i-2)
...
DP I am decisive is weak explosion, the first time to write incredibly the first jump of the +1, think of the next a
#include <cstdio> #include <cstring> #include <iostream> #include <cstdio> #include < algorithm>using namespace std; #define LL long longconst int SIZE = 50+1;int n; LL f[size];void init () { f[1]=1; f[0]=0; for (int i=2;i<=50;i++) { f[i] = 1; for (int j=1;j<i;j++) { F[i] + = F[i-j];}} } int main () { init (); while (CIN >> N) { cout << f[n] << Endl; } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Topic 1389: Abnormal jumping steps simple DP