深度优先____39级台阶

#include <stdio.h>

int count = 0;

void dfs(int all,int step)
{
    if(all>39)
        return;
    if(all==39 && step%2==0)
    {
        count++;
        return;
    }
    if(all<=37)dfs(all+2,step+1);
    if(all<=38)dfs(all+1,step+1);
}
int main()
{
    dfs(0,0);
    printf("%d\n",count);
}


//结果:51167078

 

posted on 2013-05-07 20:33  wwjyt  阅读(129)  评论(0)    收藏  举报