重生之我会用C加加了


私信TA

用户名:dotcpp0602879

访问量:3698

签 名:

放纵是本性,克制是智慧。

等  级
排  名 415
经  验 4811
参赛次数 3
文章发表 21
年  龄 21
在职情况 学生
学  校 江西科技师范大学
专  业 大数据

  自我简介:

我唯一会的而且擅长的也就只有Python,如果不能在Python领域取得好的成绩,那人生还有什么意义呢!

解题思路:

注意事项:

参考代码:


def dfs(n,step):

    for i in range(n//2+1):

        if exist[i]: # 存在直接用

            target=list1[step]

            temp[target]+=temp[i]

        else:

            step+=1

            list1[step]=i

            dfs(i,step)

            # 回溯注意

            exist[i]=1 # 打上标记

            temp[list1[step-1]]+=temp[list1[step]] #step 分解出step+1 回溯前记得累计上

            list1[step]=0

            step-=1

    

    


n=eval(input())

exist=list(0 for i in range(1001)) # 判断数是否可以直接获取

temp=list(0 for i in range(1001))

exist[0],temp[0]=1,1

result=[0]

list1=[0 for i in range(1001)]

list1[0]=n

dfs(n,0)

print(temp[n])



 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区