Zstu Learning algorithm 017--dfs--Monkey Mountain climbing

Source: Internet
Author: User

Description A monkey in a hill not more than 30 mountain climbing jump, the monkey up a step can jump 1 or jump 3, try to find out how many different climbing method up the hill input multiple sets of test data, each group input 1 integer n, Indicates the number of steps of the hill output for the input integer n to find out how many kinds of crawl sample input
30
Sample Output
58425
HINT

To the general effect: Classic DFS

#include <cstdio>intn, tot;voidDfsintsum) {     if(Sum = =N) {Tot++; return; }     if(Sum >N)return ; DFS (sum+1); DFS (sum+3);}intMain () { while(~SCANF ("%d",&N)) {Tot=0; DFS (0); printf ("%d\n", tot); }    return 0;}
View Code

Zstu Learning algorithm 017--dfs--Monkey Mountain climbing

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.