Topic 1389: Abnormal jumping steps simple DP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.